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.

I'm trying to make an tikz plot from a matlab plot. The problem is that de y label is on the y axis.

Plot image

I used the following code:

\begin{tikzpicture}

\begin{axis}[%
width=\figurewidth,
height=\figureheight,
scale only axis,
xmin=0, xmax=320,
xlabel={$\text{Debiet [m}^\text{3}\text{/h]}$},
xmajorgrids,
ymin=0, ymax=9e-006,
ylabel={$\text{d}_{\text{p,100\%}}\text{ [m]}$},
ymajorgrids,
axis lines=left,
title={ },
legend style={nodes=right}]
\addplot [
color=black,
solid
]
coordinates{
...
addlegendentry{$\text{d}_{\text{p,100\%}}\text{ bij ideale aanstroming}$};

\end{axis}
\end{tikzpicture}

.

I tried several things but it still doesn't work. Is there a way I can move the y label to the right or use a common scaling factor on the y-axis.

share|improve this question
    
I assume you mean "move the y label to the left"? –  Jake Apr 1 '12 at 11:25
    
possible duplicate of ylabel postion with pgfplots –  Torbjørn T. Apr 1 '12 at 12:45
    
@TorbjørnT.: It's not an exact duplicate, since this question also asks for a way to use a common scaling factor. –  Jake Apr 1 '12 at 12:54
    
@Jake Sorry, you're right. I missed that last part. –  Torbjørn T. Apr 1 '12 at 12:55
add comment

2 Answers

You can use a common scaling factor by supplying the option scaled y ticks={base 10:6}, which will multiply all y ticks with 10^6 and add the scaling factor 10^-6 to the top of the axis.

\documentclass{article}

\usepackage{pgfplots}
\usepackage{amsmath}

\begin{document}
\begin{tikzpicture}

\begin{axis}[%
scale only axis,
xmin=0, xmax=320,
xlabel={$\text{Debiet [m}^\text{3}\text{/h]}$},
xmajorgrids,
ymin=0, ymax=9e-006,scaled y ticks={base 10:6},
ylabel={$\text{d}_{\text{p,100\%}}\text{ [m]}$},
ymajorgrids,
axis lines=left,
title={ },
legend style={nodes=right}]
\addplot [
color=black,
solid
] coordinates {(0,7e-6) (320,3e-6)};
\addlegendentry{$\text{d}_{\text{p,100\%}}\text{ bij ideale aanstroming}$};

\end{axis}
\end{tikzpicture}
\end{document}

To avoid the y axis label colliding with the tick labels, you can set the version to use to at least compat=1.3, which will use the special anchor near ticklabel for the axis labels.

\documentclass{article}

\usepackage{pgfplots}
\usepackage{amsmath}

\begin{document}
\begin{tikzpicture}

\begin{axis}[%
compat=newest,
scale only axis,
xmin=0, xmax=320,
xlabel={$\text{Debiet [m}^\text{3}\text{/h]}$},
xmajorgrids,
ymin=0, ymax=9e-006,
ylabel={$\text{d}_{\text{p,100\%}}\text{ [m]}$},
ymajorgrids,
axis lines=left,
title={ },
legend style={nodes=right}]
\addplot [
color=black,
solid
] coordinates {(0,7e-6) (320,3e-6)};
\addlegendentry{$\text{d}_{\text{p,100\%}}\text{ bij ideale aanstroming}$};

\end{axis}
\end{tikzpicture}
\end{document}
share|improve this answer
add comment

Newer versions of pgfplots handle this problem automatically, but you have to call it. You can use \pgfplotsset{compat=newest} to set the compatibility globally, or use compat=newest within the \begin{axis}[ ... ] options.

This option automatically adjusts the spacing of the label to avoid the tick marks. If you want to adjust this further, use ylabel shift={dimension} option (which only works when compat=newest is set.)

share|improve this answer
1  
While this is correct, I would like to note that compat=newest means that the code in question will always and without further notice adapt changes of future versions. It is best-practice to prefer a fixed version, for example compat=1.4 to ensure that your figure will always look the same even in future versions. –  Christian Feuersänger Apr 1 '12 at 18:01
    
Good point. I haven't used pgfplots long enough to make old code obsolete, and many times the features I want exist only in the newer revisions, so I generally use newest. But your point is well taken. –  GregH Apr 3 '12 at 12:29
add comment

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.