Seite 1 von 1

Achseneinteilung pgfplots

Verfasst: Do 28. Jan 2016, 22:34
von planlosernutzer
Hallo :-)

Meine Frage zu pgfplots: Ich hab logarthmische Achsen und möchte meine Achseneinteilung auf der y-Achse verändern.

An der y-Achse sollen Folgende Werte erscheinen: 5*10e1 , 10e2 , 2*10e2 Diese sollen jedoch in Dezimaldarstellung d.h. 50, 100, 200 dargestellt werden. Das logarthmische Gitter welches vorhanden ist soll erhalten bleiben.
\documentclass[12pt]{scrartcl}

\usepackage[paperwidth=18cm, paperheight=12cm]{geometry}

%Digrammzeug
\usepackage{pgfplots}


\begin{document}
	
	\thispagestyle{empty} % um die Seitenzahl zu endfernen
	\newgeometry{left=0.1cm, right=0.1cm, top=0.1cm, bottom=0.1cm}
	
	
	\begin{figure}
		\centering
		\begin{tikzpicture}
		\begin{loglogaxis}[
		axis x line=bottom,
		axis y line=left,
		ymax = 2.1*10^2,
		xlabel=N (log),
		ylabel=$ \mathrm{S_a} $ in MPa (log),
		every axis x label/.style={
			at={(ticklabel* cs:1.05)},
			anchor=west,
		},
		every axis y label/.style={
			at={(ticklabel* cs:1.05)},
			anchor=south,
		},
		ytick={10, 100},	
		scale=1.6,
		grid=both,
		tick align=outside,
		tickpos=left,
		]
		
		%Lasth 1
		\node at (axis cs: 10^5.25,10^2.193) {Lasthorizont I};
		
		%Lasth 2
		\node at (axis cs: 10^6.2,10^1.955) {Lasthorizont II};
		
		%Lasth 1 - 2 Gerade
		\addplot[black, mark=square*] coordinates { (50966, 155.74) (477468, 90.16)};
		
		%Lasth 2 - N_D Gerade
		\addplot[black,no marks] coordinates { (477468, 90.16) (2.5*10^6, 60.16677272)};
		
		%Dauerfestigkeit
		\addplot[black, mark=square*, mark indices={1}] coordinates { (2.5*10^6, 60.16677272) (10^7, 60.16677272)};
		\addplot[black, dotted, no marks] coordinates { (2.5*10^6, 60.16677272) (10^7.3, 60.16677272) };	
		\addplot[black, dashed] coordinates { (10^4, 60.16677272) (2.5*10^6, 60.16677272) };
		
		%Beschriftung
		\addplot[dashed] coordinates { (2.5*10^6, 60.16677272) (2.5*10^6, 10^1.7)};
		\node at (axis cs: 10^5.4,10^1.85) {Zeitfestigkeit};
		\node at (axis cs: 10^5.4,10^1.74) {Dauerfestigkeit};
		\node at (axis cs: 10^6.85,10^1.73) {$ N_D=2,5\cdot10^6 $};
		\node at (axis cs: 10^4.4,10^1.8) {$ S_{aD} \approx $ 60.17};
	
		%Lasthorizont III
		\addplot[black, thick, mark=x] coordinates {(180000, 117.49)};
		\node at (axis cs: 10^5.8, 10^2.07) {Lasthorizont III};
		
		\end{loglogaxis}
		\end{tikzpicture}
	\end{figure}
	
	
\end{document}

Verfasst: Fr 29. Jan 2016, 14:23
von quietscheentchen
Hallo,

ersetze die Zeilen
      every axis x label/.style={
         at={(ticklabel* cs:1.05)},
         anchor=west,
      },
      every axis y label/.style={
         at={(ticklabel* cs:1.05)},
         anchor=south,
      },
      ytick={10, 100},   
durch
yticklabels={50,100,200},
	  ytick={50,100,200}, 
Außerdem solltest du noch etwas wie
ymin = 49,
einfügen, damit die Beschriftung 50 überhaupt angezeigt wird.

Der fertige Code ist dann:
\documentclass[12pt]{scrartcl}

\usepackage[paperwidth=18cm, paperheight=12cm]{geometry}

%Digrammzeug
\usepackage{pgfplots}


\begin{document}
   
   \thispagestyle{empty} % um die Seitenzahl zu endfernen
   \newgeometry{left=0.1cm, right=0.1cm, top=0.1cm, bottom=0.1cm}
   
   
   \begin{figure}
      \centering
      \begin{tikzpicture}
      \begin{loglogaxis}[
      axis x line=bottom,
      axis y line=left,
      ymax = 2.1*10^2,
      ymin = 49,
      xlabel=N (log),
      ylabel=$ \mathrm{S_a} $ in MPa (log),
      yticklabels={50,100,200},
	  ytick={50,100,200}, 
      scale=1.6,
      grid=both,
      tick align=outside,
      tickpos=left,
      ]
     
      %Lasth 1
      \node at (axis cs: 10^5.25,10^2.193) {Lasthorizont I};
     
      %Lasth 2
      \node at (axis cs: 10^6.2,10^1.955) {Lasthorizont II};
     
      %Lasth 1 - 2 Gerade
      \addplot[black, mark=square*] coordinates { (50966, 155.74) (477468, 90.16)};
     
      %Lasth 2 - N_D Gerade
      \addplot[black,no marks] coordinates { (477468, 90.16) (2.5*10^6, 60.16677272)};
     
      %Dauerfestigkeit
      \addplot[black, mark=square*, mark indices={1}] coordinates { (2.5*10^6, 60.16677272) (10^7, 60.16677272)};
      \addplot[black, dotted, no marks] coordinates { (2.5*10^6, 60.16677272) (10^7.3, 60.16677272) };  
      \addplot[black, dashed] coordinates { (10^4, 60.16677272) (2.5*10^6, 60.16677272) };
     
      %Beschriftung
      \addplot[dashed] coordinates { (2.5*10^6, 60.16677272) (2.5*10^6, 10^1.7)};
      \node at (axis cs: 10^5.4,10^1.85) {Zeitfestigkeit};
      \node at (axis cs: 10^5.4,10^1.74) {Dauerfestigkeit};
      \node at (axis cs: 10^6.85,10^1.73) {$ N_D=2,5\cdot10^6 $};
      \node at (axis cs: 10^4.4,10^1.8) {$ S_{aD} \approx $ 60.17};
   
      %Lasthorizont III
      \addplot[black, thick, mark=x] coordinates {(180000, 117.49)};
      \node at (axis cs: 10^5.8, 10^2.07) {Lasthorizont III};
     
      \end{loglogaxis}
      \end{tikzpicture}
   \end{figure}
   
   
\end{document}

Verfasst: Fr 29. Jan 2016, 15:57
von planlosernutzer
@quietscheentchen
Danke :-)
Leider ist nur jetzt nur das Gitter und die Ticks für die Werte zwischen 50 und 100 bzw. 100 und 200 weg. Hast du eine Idee wie man die wider einbauen kann?

Verfasst: Sa 30. Jan 2016, 12:18
von quietscheentchen
Ich weiß nicht, ob es eleganter geht, aber so
      yticklabels={50,,,,,100,200},
	  ytick={50,60,70,80,90,100,200}, 
sind die Striche da.