PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Tikxpicture sinus verlauf um 270° drehen



Fretschi
19-02-2014, 22:42
Hallo zusammen,

ich brauche in einer Grafik 2mal eine Sinus-Kurve, wovon eine um 270° gedreht werden soll.

Wenn ich einfach \draw (0,0) sin () cos (); mit den entsprechenden Koordinaten eintippe erhalte ich einen komischen Verlauf.

Wie muss ich meinen Code verändern, dass ich in der von oben nach unten verlaufenden Kurve eine "schöne" sinus-kurve habe.

Schon mal Danke für eure Hilfe!



\documentclass{scrartcl}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}

%%%%%%%%%
%% um 270° gedreht
%%%%%%%%%
\draw[dashed] (-0.75,2) -- (-0.75,-5);
\draw [->](-0.75,-5) -- (-0.75,-9) node[rotate=270,at end,anchor=north]{t};
\draw [->](-2.25,-5) -- (0.75,-5) node[rotate=270, at end,anchor=east]{s};

\fill (-0.75,-5) circle (1pt);
\draw [->] (-0.75,-5.5)--(0.25,-5.5);
\fill (0.25,-5.5) circle (1pt);
\fill (-0.75,-6) circle (1pt);
\draw [->] (-0.75,-6.5)--(-1.75,-6.5);
\fill (-1.75,-6.5) circle (1pt);
\fill (-0.75,-7) circle (1pt);
\fill (0.25,-7.5) circle (1pt);
\fill (-0.75,-8) circle (1pt);
\fill (-1.75,-8.5) circle (1pt);
\draw (-0.75,-5) cos (0.25,-5.5) sin (-0.75,-6) cos (-1.75,-6.5) sin (-0.75,-7) cos (0.25,-7.5);
%%%%%%%%%
%% normal
%%%%%%%%%
\draw [->] (3,-8) -- (10,-8) node[at end,anchor=north east]{Weg $\frac{s}{m}$};
\draw [->] (3,-11) -- (3,-5) node[at end,anchor=east] {Druck $\frac{P}{Pa}$};
\draw (3,-8) sin (4,-7) cos (5,-8) sin (6,-9) cos (7,-8) sin (8,-7);
\end{tikzpicture}
\end{document}

Magger
20-02-2014, 07:47
mittels


\draw[domain=0:720,samples=201,rotate=270] plot (\x/360,{sin(\x)});


bekommst du erstmal eine schöne Sinuskurve hin, die um 270° gedreht ist. Die entsprechende Skalierung in Höhe und Breite kann mit dem Teiler \x/360 bzw. einem Vorfaktor vor der Sinus-Funktion eingestellt werden.

Diese Funktion musst du dann nur noch an deine gewünschte Stelle schieben.

Magger
20-02-2014, 07:55
Hier ist dein komplettes Beispiel:


\documentclass{scrartcl}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}

%%%%%%%%%
%% um 270° gedreht
%%%%%%%%%
\draw[dashed] (-0.75,2) -- (-0.75,-5);
\draw [->](-0.75,-5) -- (-0.75,-9) node[rotate=270,at end,anchor=north]{t};
\draw [->](-2.25,-5) -- (0.75,-5) node[rotate=270, at end,anchor=east]{s};

\fill (-0.75,-5) circle (1pt);
\draw [->] (-0.75,-5.5)--(0.25,-5.5);
\fill (0.25,-5.5) circle (1pt);
\fill (-0.75,-6) circle (1pt);
\draw [->] (-0.75,-6.5)--(-1.75,-6.5);
\fill (-1.75,-6.5) circle (1pt);
\fill (-0.75,-7) circle (1pt);
\fill (0.25,-7.5) circle (1pt);
\fill (-0.75,-8) circle (1pt);
\fill (-1.75,-8.5) circle (1pt);
\draw (-0.75,-5) cos (0.25,-5.5) sin (-0.75,-6) cos (-1.75,-6.5) sin (-0.75,-7) cos (0.25,-7.5);

\draw[color=blue,domain=0:450,samples=451,xshift=-0.75cm,yshift=-5cm,rotate=270] plot (\x/180,{sin(\x)});

%%%%%%%%%
%% normal
%%%%%%%%%
\draw [->] (3,-8) -- (10,-8) node[at end,anchor=north east]{Weg $\frac{s}{m}$};
\draw [->] (3,-11) -- (3,-5) node[at end,anchor=east] {Druck $\frac{P}{Pa}$};
\draw (3,-8) sin (4,-7) cos (5,-8) sin (6,-9) cos (7,-8) sin (8,-7);
\end{tikzpicture}
\end{document}

Die neue Sinuskurve ist blau.

Fretschi
23-02-2014, 18:02
Vielen Dank für die Hilfe, klappt super :)



\draw[domain=0:720,samples=201,rotate=270] plot (\x/360,{sin(\x)});


domain scheint Start- und Endpunkt fest zu legen.
samples gibt vermutlich die verwendeten Punkte an (je mehr, desto "flüssiger" ist der verlauf)

Magger
23-02-2014, 21:25
So ist es, steht auch im pgf/TikZ-Handbuch beschrieben.