PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : tikz pgflots achsenbeschriftung in dezimalzahlen



zac
04-04-2012, 09:57
ich habe bei folgendem beispiel, das problem, dass die y-Achse nicht in Dezimalzahlen beschriftet wird. Die Beschriftung ist dann so groß, dass das 1/Q (Beschrigtung der Achse) nicht mehr zu sehen ist.


\documentclass[a4paper]{scrartcl} %Dokumentklasse - für kürzere Artikel und Aufsätze
\usepackage[ansinew]{inputenc} %deutsche Zeichen
%Windows ANSI-Kodierung, Erweiterung für Latin-1
\usepackage[ngerman]{babel} %deutsche Silbentrennung
\usepackage[a4paper,left=20mm,right=20mm, top=25mm, bottom=25mm]{geometry}
%Seitenränder einstellen


\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\begin{document}
\begin{tikzpicture}
\begin{axis}[legend pos=outer north east,
xmin=0,
xmax=8,
xlabel={m},
ylabel={$1/Q$},
ymin=0,
ymax=0.04,
grid=major,
scale=1.5
]

\addplot[blue,no marks] table [
y={create col/linear regression={y=Y}}]
{
X Y
0 0.007289296
1 0.015024227
2 0.018334649
3 0.018812114
5 0.025369298
7 0.026897185
};
\xdef\slopea{\pgfplotstableregressiona}
\xdef\slopeb{\pgfplotstableregressionb}
\addlegendentry{%
$\pgfmathprintnumber{\slopea} \cdot x
\pgfmathprintnumber[print sign]{\slopeb}$}
% \addlegendentry{Ausgleichsgerade für $m=0$}
\addplot[only marks]
coordinates {
(0, 0.007289296)
(1, 0.015024227)
(2, 0.018334649)
(3, 0.018812114)
(5, 0.025369298)
(7, 0.026897185)
};
\addlegendentry{Messwerte}
\end{axis}
\end{tikzpicture}\\[1em]
\end{document}

zac
09-04-2012, 16:31
Also ich hab das jetzt herausgefunden und vielleicht interessiert das ja irgendwann mal jemand:


\documentclass[a4paper]{scrartcl} %Dokumentklasse - für kürzere Artikel und Aufsätze
\usepackage[ansinew]{inputenc} %deutsche Zeichen
%Windows ANSI-Kodierung, Erweiterung für Latin-1
\usepackage[ngerman]{babel} %deutsche Silbentrennung
\usepackage[a4paper,left=20mm,right=20mm, top=25mm, bottom=25mm]{geometry}
%Seitenränder einstellen


\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\begin{document}
\begin{tikzpicture}
\tikzset{every y tick label/.append style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=3}}
\begin{axis}[legend pos=outer north east,
xmin=0,
xmax=8,
xlabel={m},
ylabel={$1/Q$},
y label style={at={(-0.05,0.5)}},
ymin=0,
ymax=0.04,
grid=major,
scale=1.5
]

\addplot[blue,no marks] table [
y={create col/linear regression={y=Y}}]
{
X Y
0 0.007289296
1 0.015024227
2 0.018334649
3 0.018812114
5 0.025369298
7 0.026897185
};
\xdef\slopea{\pgfplotstableregressiona}
\xdef\slopeb{\pgfplotstableregressionb}
\addlegendentry{%
$\pgfmathprintnumber{\slopea} \cdot x
\pgfmathprintnumber[print sign]{\slopeb}$}
% \addlegendentry{Ausgleichsgerade für $m=0$}
\addplot[only marks]
coordinates {
(0, 0.007289296)
(1, 0.015024227)
(2, 0.018334649)
(3, 0.018812114)
(5, 0.025369298)
(7, 0.026897185)
};
\addlegendentry{Messwerte}
\end{axis}
\end{tikzpicture}\\[1em]
\end{document}

humpenjack
16-04-2013, 08:24
Besten Dank dafür - genau das habe ich gesucht! :)