Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

From the tikzscale documentation I understand, that it is supposed to keep font sizes constant. However, this does not seem to apply to axis ticks or axis labels from pgfplots' axis environment. Also, node placement seems to be messed up. This is illustrated in the following example:

\documentclass[10pt,crop]{standalone}
\usepackage[english]{babel}
\usepackage{pgfplots}
\usepackage{tikzscale}
\usepackage{filecontents}
\pgfplotsset{compat=1.9}
\begin{document}
\begin{filecontents}{font-size.tikz}
\begin{tikzpicture}
  \begin{axis}[
  width=150pt,
  height=150pt,
  xmin=-1,xmax=1,ymin=-1,ymax=1,
  xlabel=xlabel,
  ylabel=ylabel,
  ]
  \addplot coordinates{ 
  (-0.9,-0.9)
  (0.9,0.9)
  };
  \node[anchor=west] at (axis cs:-1,0) {01};
  \coordinate (a) at (axis cs:-1,0);
  \end{axis}
  \node[anchor=west,red] at (a) {02};
\end{tikzpicture}
\end{filecontents}

Some text in font size 10pt.
\input{font-size.tikz}
\includegraphics[width=250pt]{font-size.tikz}
\end{document}

enter image description here
In the first plot, created without tikzscale, all labels and nodes have the correct font size and node "02" is placed correctly. In the second plot, however, font sizes for the labels are obviously larger. The same holds for node "01". Interestingly, node "02" has the correct font size, but the placement is wrong. Is there a way to correctly scale the axis (or groupplot) environment while preserving the labels' and nodes' font sizes as well as placing nodes at the correct position?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

Don't specify

width=150pt,
height=150pt,

to the axis in the options. This doesn't make sense since you are controlling the dimensions from outside. Further, there is also axisratio key provided if you want different axis ratios.

\documentclass[10pt,crop]{standalone}
\usepackage[english]{babel}
\usepackage{pgfplots}
\usepackage{tikzscale}
\usepackage{filecontents}
\pgfplotsset{compat=1.9}
\begin{document}
\begin{filecontents}{font-size.tikz}
\begin{tikzpicture}[transform shape]
  \begin{axis}[
%  width=150pt,               %% don't give this
%  height=150pt,              %% don't give this
  xmin=-1,xmax=1,ymin=-1,ymax=1,
  xlabel=xlabel,
  ylabel=ylabel,
  ]
  \addplot coordinates{
  (-0.9,-0.9)
  (0.9,0.9)
  };
  \node[anchor=west] at (axis cs:-1,0) {01};
  \coordinate (a) at (axis cs:-1,0);
  \end{axis}
  \node[anchor=west,red] at (a) {02};
\end{tikzpicture}
\end{filecontents}

Some text in font size 10pt.
\input{font-size.tikz}
\includegraphics[width=250pt]{font-size.tikz}   %% use width=250pt,axisratio=2 to see the change
\end{document}

enter image description here

share|improve this answer
    
Unfortunately, this does not work for groupplots. I posted a follow-up question here: link –  Janek Apr 28 at 16:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.