Hi Joel,

you can
a) manually fix your tick labels using
ytick={0,1,...,5},
yticklabels={00,01,02,03,04,05},
or
b) make a more-or-less general approach which fixes it automatically using
     \begin{axis}[yticklabel={%
         $
         \ifdim\tick pt<10pt
             0%
         \fi
         \pgfmathprintnumber{\tick}$%
     },%
     ]
...
Here, the \ifdim\tick pt < 10pt  is a TeX comparison which works if the 
numbers are small. The 'pt' suffix is here because TeX can only compare 
in units of point.

The approach will probably fit into your approach, although it needs to 
be modified for negative numbers.

c) try to experiment with the sizes of the label nodes which is 
preferrable over a) and b). Tikz offers the minimum width approach:
yticklabel style={minimum width=3em}

d) exclude the axis descriptions explicitly from the external image's 
bounding box. This last approach is what I have done to fix the 
alignment in such cases.

To do so, you can use the 'trim axis right' and/or 'trim axis left'  
features. The following example is copied from the manual, section 
"Alignment":

\begin{center}
\begin{tabular}{rl}
     \begin{tikzpicture}[baseline,trim axis left]
         \begin{axis}
              \addplot {x};
         \end{axis}
     \end{tikzpicture}
&
     \begin{tikzpicture}[baseline,trim axis right]
     \begin{axis}[
         ylabel={$f(x)=x^2$},
         yticklabel pos=right,
         ylabel style={font=\Huge}]
         \addplot {x^2};
     \end{axis}
     \end{tikzpicture}
     \\
     %
     \begin{tikzpicture}[baseline,trim axis left]
     \begin{axis}[xlabel=$x$,xlabel style={font=\Huge}]
         \addplot {x^3};
     \end{axis}
     \end{tikzpicture}%
&
     \begin{tikzpicture}[baseline,trim axis right]
     \begin{axis}[yticklabel pos=right]
         \addplot {x^4};
     \end{axis}
     \end{tikzpicture}%
     \\
\end{tabular}%
\end{center}

I hope one of the approaches is what you had in mind. I encourage you to 
consider the last one.

Best regards

Christian

PS
I posted a copy of this reply to the mailing list since it might be of 
general interest.

Am 31.07.2011 05:18, schrieb Joel:
> Hello Christian,
>
> I have two plots which I externalize to an EPS file. However, the y-axis tick 
> labels are different: the first plot has 0, 1, ... , 5, while the second has 
> 0, 1, ..., 10. This causes the plots to have a slightly different width, 
> since the 2nd plot has a wider y-axis tick label.
>
> Is it possible to print the axis tick labels in a fixed width format, padding 
> shorter labels with spaces, so the plots will have the same width. For 
> example:
> plot 1 y tick labels:<space>0 ...<space>5
> plot 2 y tick labels:<space>0 ... 10
>
> TIA,
> Joel.


------------------------------------------------------------------------------
Got Input?   Slashdot Needs You.
Take our quick survey online.  Come on, we don't ask for help often.
Plus, you'll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
_______________________________________________
Pgfplots-features mailing list
Pgfplots-features@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pgfplots-features

Reply via email to