Seite 1 von 1
TikZ/PGFplots: Ticklabels und Exponent entfernen
Verfasst: Di 16. Aug 2011, 09:51
von Solmath
Hallo zusammen,
für meine Studienarbeit benötige ich diverse Plots, die ich mit matlab2tikz generiere und dann in LaTeX einbinde.
Nun würde ich gerne die y-Achse skalieren (eigentlich die y-Werte). Das heißt anstatt von -1*10^-2 bis 1*10^-2 soll sie von -1,5 bis 1,5 gehen.
Mein Plan war, einfach die alten y-Ticklabels zu entfernen und durch die gewünschten zu ersetzen (siehe Kommentar), allerdings steht dann immer noch das 10^-2 an der Achse. Ich habe schon mit /pgf/number format/ rumgespielt, allerdings brachte mich das nicht wirklich weiter.
Wäre schön, wenn mir jemand helfen könnte.
Gruß,
Solmath
\documentclass[10pt, a4paper]{scrreprt}
\usepackage[ngerman]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[%
view={0}{90},
scale only axis,
xmin=0, xmax=100,
ymin=-0.011, ymax=0.011,
xlabel={x},
ylabel={y},
xmajorgrids,
%ytick=\empty,
%extra y ticks={-0.01,0,0.01},
%extra y tick style={grid=major},
%extra y tick labels={-1.5,0,1.5}
]
\addplot [
color=blue,
only marks,
mark=*,
mark options={scale=.5,solid}
]
coordinates{ (97.2222,0.00478921) (22.2222,4.63494e-005) (0,0) (5.55556,0.000807916) (11.1111,-0.00347324) (16.6667,0.000472656) (22.2222,4.73494e-005) (27.7778,-0.000544554) (30.5556,-8.91581e-005) (36.1111,-0.000102572) (41.6667,0.00208867) (47.2222,0.00181665) (52.7778,-0.00114078) (58.3333,-0.00428186) (63.8889,0.000145472) (69.4444,0.0061464) (72.2222,0.00458039) (77.7778,-0.00197474) (83.3333,-0.0046262) (88.8889,-0.00244615) (94.4444,0.00331435) (100,0)
};
\end{axis}
\end{tikzpicture}
\end{document}
Verfasst: Mo 22. Aug 2011, 21:06
von Feuersaenger
Hallo Solmath,
Das "tick scaling" deaktiviert man, indem man "scaled ticks=false" zu der Optionsliste hinzufuegt.
Zusammen sollte also
ytick={-0.01,0,0.01},
yticklabels={-1.5,0,1.5},
scaled ticks=false,
zum gewuenschten Ergebnis fuehren (wobei es mir tatsaechlich eher ein bug zu sein scheint, dass man das tick scaling noch extra ausmachen muss...)
Mit liebem Gruss
Christian
Verfasst: Mi 31. Aug 2011, 10:44
von Solmath
Vielen Dank, das ist genau wonach ich gesucht habe.
Ticklabels und Exponent entfernen
Verfasst: Di 9. Apr 2019, 09:45
von TexFan
Hallo,
leider schaffe ich es nicht, die Notation der Ticks auf der x-Achse von 10^x auf normale Zahlenwerte zu setzen (10²,10³ -> 100,1000). Ich habe bereits die Optionen
scaled ticks=false
und
ticklabel style={
/pgf/number format/fixed,
}
gesetzt. Es funktioniert leider immer noch nicht!? Hat jemand noch eine Idee, woran es hakt?
Besten Dank für Eure Hilfe!
\documentclass{standalone}
\usepackage{pgfplots}
\usepackage{xcolor}
\usepackage{tikz}
\begin{document}
\definecolor{mycolor1}{rgb}{0.00000,0.44700,0.74100}%
\definecolor{mycolor2}{rgb}{0.85000,0.32500,0.09800}%
%
\begin{tikzpicture}
\small
\begin{axis}[%
width=4cm,
height=2.75cm,
at={(0cm,-1.0cm)},
scale only axis,
ticklabel style={
/pgf/number format/.cd,
/pgf/number format/fixed,
use comma,% Komma als Dezimaltrenner
1000 sep = {}% keine Tausendertrennung
},
scaled ticks=false, % keine Notation mit 10^x
xmin=100,
xmax=6000,
xmode=log,
ymin=30,
ymax=80,
axis background/.style={fill=white},
title style={align=center},
title={Terzbandspektrum},
grid=major,
minor y tick num=1,
yminorgrids,
xlabel={$f / Hz$ },
xtick={200,500,1000,2000,5000},
ytick={40,60,80},
ylabel={$Pegel / dB$},
legend style={legend cell align=right, align=left,legend pos=outer north east, draw=white!15!black}
]
\addplot [color=mycolor1]
table[row sep=crcr]{%
22.40 57.38164902\\
28.2 57.38164902\\
28.2 54.50539398\\
35.5 54.50539398\\
35.5 57.56157684\\
44.7 57.56157684\\
44.7 56.78892136\\
56.2 56.78892136\\
56.2 65.44906616\\
70.8 65.44906616\\
70.8 70.22911072\\
89.1 70.22911072\\
89.1 51.1942749\\
112 51.1942749\\
112 52.95914078\\
141 52.95914078\\
141 58.49982452\\
178 58.49982452\\
178 60.39244461\\
224 60.39244461\\
224 56.58963394\\
282 56.58963394\\
282 62.63325882\\
355 62.63325882\\
355 59.06183624\\
447 59.06183624\\
447 56.40215302\\
562 56.40215302\\
562 51.47289658\\
708 51.47289658\\
708 53.27006912\\
891 53.27006912\\
891 50.8656311\\
1122 50.8656311\\
1122 49.80443954\\
1413 49.80443954\\
1413 47.67407608\\
1778 47.67407608\\
1778 46.31458282\\
2239 46.31458282\\
2239 43.07452774\\
2818 43.07452774\\
2818 45.09469986\\
3548 45.09469986\\
3548 48.12972641\\
4467 48.12972641\\
4467 53.5567627\\
5623 53.5567627\\
5623 51.10303497\\
6000 51.10303497\\
};
\addplot [color=mycolor2]
table[row sep=crcr]{%
22.4 57.41030884\\
28.2 53.53193283\\
35.5 57.0448494\\
44.7 57.02972412\\
56.2 68.12867737\\
70.8 72.91301727\\
89.1 49.41585541\\
112 54.9017868\\
141 60.50126648\\
178 61.48514557\\
224 58.51675415\\
282 62.36026764\\
355 62.6497345\\
447 68.23018646\\
562 63.29843521\\
708 61.48404694\\
891 58.69266891\\
1122 58.21083069\\
1413 58.98439026\\
1778 54.00564575\\
2239 51.39455032\\
2818 50.15164566\\
3548 51.58002853\\
4467 54.46299362\\
5623 54.08631134\\
6000 54.08631134\\
};
\end{axis}
\end{tikzpicture}%
\end{document}
Verfasst: Di 9. Apr 2019, 10:23
von Bartman
Hänge Dich besser nicht an alte Themen an.
pgfplots lädt
pgf/TikZ, welches
xcolor lädt.
Vergiss nicht, der
Option compat einen passenden Wert zuzuweisen.
Der Abschnitt 4.13.2 in
pgfplots könnte Dich interessieren.
Benutze das Paket
siunitx für physikalische Einheiten.
Ticklabels und Exponent entfernen
Verfasst: Di 9. Apr 2019, 11:59
von TexFan
Danke für die schnelle Rückmeldung und die Tipps, Bartman!
Mit dem Quellenhinweis im PGFPlots Manual habe ich die Lösung gefunden.
Zur Vollständigkeit für alle, die auf diesen Thread stoßen:
Die Option
log ticks with fixed point,
muss noch gesetzt werden!
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{xcolor}
\usepackage{tikz}
\begin{document}
\definecolor{mycolor1}{rgb}{0.00000,0.44700,0.74100}%
\definecolor{mycolor2}{rgb}{0.85000,0.32500,0.09800}%
\definecolor{mycolor3}{rgb}{0.92900,0.69400,0.12500}%
\definecolor{mycolor4}{rgb}{0.49400,0.18400,0.55600}%
\definecolor{mycolor5}{rgb}{0.46600,0.67400,0.18800}%
%
\begin{tikzpicture}
\small
\begin{semilogxaxis}[%
width=4cm,
height=2.75cm,
at={(0cm,-1.0cm)},
scale only axis,
log ticks with fixed point, % muss fuer Nutzer gesteuerte Ticks hinzugefuegt werden
ticklabel style={
/pgf/number format/.cd,
/pgf/number format/fixed,
use comma,% Komma als Dezimaltrenner
1000 sep = {}% keine Tausendertrennung
},
scaled ticks=false, % keine Notation mit 10^x
xmin=100,
xmax=6000,
xmode=log,
ymin=30,
ymax=80,
axis background/.style={fill=white},
title style={align=center},
title={Terzbandspektrum},
grid=major,
minor y tick num=1,
yminorgrids,
xlabel={$f / Hz$ },
xtick={200,500,1000,2000,5000},
ytick={40,60,80},
ylabel={$Pegel / dB$},
legend style={legend cell align=right, align=left,legend pos=outer north east, draw=white!15!black}
]
\addplot [color=mycolor1]
table[row sep=crcr]{%
22.40 57.38164902\\
28.2 57.38164902\\
28.2 54.50539398\\
35.5 54.50539398\\
35.5 57.56157684\\
44.7 57.56157684\\
44.7 56.78892136\\
56.2 56.78892136\\
56.2 65.44906616\\
70.8 65.44906616\\
70.8 70.22911072\\
89.1 70.22911072\\
89.1 51.1942749\\
112 51.1942749\\
112 52.95914078\\
141 52.95914078\\
141 58.49982452\\
178 58.49982452\\
178 60.39244461\\
224 60.39244461\\
224 56.58963394\\
282 56.58963394\\
282 62.63325882\\
355 62.63325882\\
355 59.06183624\\
447 59.06183624\\
447 56.40215302\\
562 56.40215302\\
562 51.47289658\\
708 51.47289658\\
708 53.27006912\\
891 53.27006912\\
891 50.8656311\\
1122 50.8656311\\
1122 49.80443954\\
1413 49.80443954\\
1413 47.67407608\\
1778 47.67407608\\
1778 46.31458282\\
2239 46.31458282\\
2239 43.07452774\\
2818 43.07452774\\
2818 45.09469986\\
3548 45.09469986\\
3548 48.12972641\\
4467 48.12972641\\
4467 53.5567627\\
5623 53.5567627\\
5623 51.10303497\\
6000 51.10303497\\
};
\addplot [color=mycolor2]
table[row sep=crcr]{%
22.4 57.41030884\\
28.2 53.53193283\\
35.5 57.0448494\\
44.7 57.02972412\\
56.2 68.12867737\\
70.8 72.91301727\\
89.1 49.41585541\\
112 54.9017868\\
141 60.50126648\\
178 61.48514557\\
224 58.51675415\\
282 62.36026764\\
355 62.6497345\\
447 68.23018646\\
562 63.29843521\\
708 61.48404694\\
891 58.69266891\\
1122 58.21083069\\
1413 58.98439026\\
1778 54.00564575\\
2239 51.39455032\\
2818 50.15164566\\
3548 51.58002853\\
4467 54.46299362\\
5623 54.08631134\\
6000 54.08631134\\
};
\end{semilogxaxis}
\end{tikzpicture}%
\end{document}
Re: TikZ/PGFplots: Ticklabels und Exponent entfernen
Verfasst: Fr 17. Nov 2023, 15:00
von RandomTexUser
Ich küss dein Herz, das funktioniert super