I am using the pgfplots
package to create some plots of data for my thesis. As an example, consider the following code:
\documentclass[a4paper]{article}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\begin{document}
\begin{tikzpicture}
\begin{semilogyaxis}[
xlabel=Cost,
ylabel=Gain]
\addplot[color=red,mark=x] coordinates {
(10,100)
(20,150)
(40,225)
(80,340)
(160,510)
(320,765)
(640,1150)
};
\addlegendentry{Plot points};
\end{semilogyaxis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{semilogyaxis}[
xscale=1.5,
xlabel=Cost,
ylabel=Gain]
\addplot[color=red,mark=x] coordinates {
(10,100)
(20,150)
(40,225)
(80,340)
(160,510)
(320,765)
(640,1150)
};
\addlegendentry{Plot points};
\end{semilogyaxis}
\end{tikzpicture}
\end{document}
For each data set I want to add a corresponding legend entry which works fine if I use \addlegendentry
. To better fit the plot on my page I am using occasionaly adding an xcale/yscale to my axis. I am only interested in the aspect ratio, since I am using the tikzscale
package to scale my plots to the current \textwidth
.
Unfortunately xscale
/yscale
does not seem to work properly with the legend entries (just render the example): If I scale down the y-axis, the legend entries are displayed above the plot, If I scale up the x-axis, the legend entries are far outside of the plot on the right side:
Is there anything I can do to obtain a desired aspect ratio with working legend entries?