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 draw graph similar to the one below with the Y-axis only on the RHS.

A graph with the Y-axis only on the right hand side.

The following MWE produces something close the desired result:

\documentclass{standalone}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}[scale=0.75]
    \begin{axis}[ylabel=Y-Axis, xlabel=X-Axis
, xmin=2, xmax=10, ymin=0, ymax=12, clip=false, axis y line*=right]
    \foreach \blah in {0.9,0.5,0.2,0.1,0.05,0.02,0.01,0.005}{
        \addplot[mark=none, domain=2:10, thick] {-ln(\blah/x^2)/ln(x)} node [pos=0,left] {$c_2=$}; %Varying c_2 values
    }
    \end{axis}
\end{tikzpicture}

\end{document}

as this image shows:

Graph showing the Y-axis almost on the right hand side, but the line on the left has disappeared

The y-axis label has not moved to the right and the box line on the left has disappeared entirely.

Any thoughts on how to make things right and get a y-axis on the right-hand side and a box line on the left-hand side?

Thanks!

share|improve this question
add comment

1 Answer

up vote 8 down vote accepted

Replace axis y line*=right with ylabel near ticks, yticklabel pos=right (Thanks Jake):

enter image description here

Code:

\documentclass{standalone}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}[scale=0.75]
    \begin{axis}[
        ylabel=Y-Axis, xlabel=X-Axis, 
        xmin=2, xmax=10, ymin=0, ymax=12, clip=false, 
        %axis y line*=right% replaced this option with:
        ylabel near ticks, yticklabel pos=right
        ]
    \foreach \blah in {0.9,0.5,0.2,0.1,0.05,0.02,0.01,0.005}{
        \addplot[mark=none, domain=2:10, thick] {-ln(\blah/x^2)/ln(x)} node [pos=0,left] {$c_2=$}; %Varying c_2 values
    }
    \end{axis}
\end{tikzpicture}

\end{document}
share|improve this answer
    
Thanks, Peter. Do you know how I can get a solid line on the left-hand side of the box? –  Richard Jul 18 '12 at 21:44
    
Perfect @Jake, thanks. Feel free to edit Peter's answer or write one up of your own. –  Richard Jul 18 '12 at 21:47
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.