I'm dealing with a bunch of plots and groupplots, and sometimes something weird happens. I'm plotting from data tables and when it comes to decide the y tick distance, sometimes the scientific notation is "well placed" (at least for my personal needs), sometimes not. Here two images:
The first image as you can see, put the 10^-2
right on the top, while the second one represents the "issue" I would like to point out. Is there a way to force the scientific notation to stay on the top of the graph? I don't get how the algorithm decide to place the notation.
Here the groupplot structure I'm currently using:
\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage{pgf,pgfplots,pgfplotstable}
\pgfplotsset{compat=newest}
\usepgfplotslibrary{colormaps}
\usepgfplotslibrary{groupplots}
\begin{document}
\begin{figure}[htbp]
\centering
\pgfplotstableread{data/v3/b1/vel/vzt.dat}{\DataTableA}
\pgfplotstableread{data/v3/b2/vel/vzt.dat}{\DataTableB}
\begin{tikzpicture}[scale=0.9]
\begin{groupplot}[group style={
group name=vztcompcross,
group size=1 by 2,
xlabels at=edge bottom,
ylabels at=edge left,
vertical sep=4em
},
xmin = 0, xmax = 30,
ymin = -0.09, ymax = 0.06,
xtick distance = 5,
ytick distance = 0.03,
xlabel={$time\;[s]$},
ylabel={$V_z\;[km/s]$},
grid = both,
grid style = {dotted},
minor tick num = 1,
major grid style = {lightgray!75},
minor grid style = {lightgray!75},
width = 0.85\textwidth,
height = 0.50\textwidth,
%scale only axis,
%legend cell align = {left},
%legend pos = north east,
legend style={at={(0.5,-0.3)},
anchor=north,legend columns=4},
legend cell align = {left},
]
\nextgroupplot[title={title1}]
\addplot[smooth, black, ultra thick] table [x = {t1a}, y = {vz1a}] {\DataTableA};
\addplot[smooth, Lavender, very thick] table [x = {t1b}, y = {vz1b}] {\DataTableA};
\addplot[smooth, Violet, very thick] table [x = {t1c}, y = {vz1c}] {\DataTableA};
\addplot[smooth, Emerald, dotted, ultra thick] table [x = {t2}, y = {vz2}] {\DataTableA};
\nextgroupplot[title={title2},
xmin = 0, xmax = 15,
ymin = -0.12, ymax = 0.06,
ytick distance = 0.03,
legend entries={n1(k),n1(k-2),n1(k-4),n2(k),n2(j),n2(j+1.5),n2(j+3)},
]
\addlegendimage{black, no markers, very thick}
\addlegendimage{Lavender, no markers, very thick}
\addlegendimage{Violet, no markers, very thick}
\addlegendimage{Emerald, dotted, no markers, ultra thick}
\addlegendimage{Apricot, no markers, very thick}
\addlegendimage{RedOrange, no markers, very thick}
\addlegendimage{MidnightBlue, no markers, very thick}
\addplot[smooth, Apricot, ultra thick] table [x = {t1a}, y = {vz1a}] {\DataTableB};
\addplot[smooth, RedOrange, very thick] table [x = {t1b}, y = {vz1b}] {\DataTableB};
\addplot[smooth, MidnightBlue, very thick] table [x = {t1c}, y = {vz1c}] {\DataTableB};
\end{groupplot}
\end{tikzpicture}
\caption{some random caption}
\end{figure}
\end{document}
scaled y ticks=true
to theaxis
environment if you haven't.DataTableB
and the fact that there is-0.12
at the lower y-axis which may be scaled to10^-1
hence not having a common factor.-12
and then put10^-2
on top ? The actual values arrive to almost-0.11
, but I put-0.12
asymin
to keep a certain distance from the x-axis. Is the double digit number (i.e. 12) that confuse the code?