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 attempting to plot two quantities on one graph each with their own vertical axis. I've got as far as the MWE below but am stuck on two problems.

  1. Can I make the right hand axis have the same line style as the left axis (I can probably fudge it with \psline but I'd like to know if there is a 'proper' way)

  2. Can I make the right hand vertical axis have an axis label like the left but with "Current [A]" (without quotes) centred on the vertical position of the axis and 0.3in to the right of the axis line.

The data files are available from capv.txt, and capi.txt.

The output from the code below look like

enter image description here

I have not provided 'real' data. When looking at the data given, one might wonder why I want two vertical axes. The two data sets I'm intending to plot have widely differing peak magnitudes and different units, but are related in time (x axis) so I find plotting them in this way desirable.

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{pstricks,pst-plot,pstricks-add}

\begin{document}

\begin{pspicture}(1,1)

\readdata{\voltage}{capv.txt}
\readdata{\current}{capi.txt}
\psset{llx=-1cm,lly=-1cm}

\psset{xAxisLabel={Time [ms]}, xAxisLabelPos={c,-0.3in}, yAxisLabel={Voltage [V]}, yAxisLabelPos={-0.3in,c}}

\begin{psgraph}[axesstyle=axes,xticksize=0 6,yticksize=0 20,subticks=0,ylabelFactor=,Dx=5,dy=1,Dy=1,Oy=-3](0,-3)(20,3){6cm}{3cm}

\pstScalePoints(1e4,1e0){}{}
\listplot[linecolor=blue,linewidth=1pt,showpoints=false]{\voltage}

\psaxes[axesstyle=axes,yticksize=0 20,ylabelFactor=,dy=1\psyunit,Dy=1,ylabelPos=right, xAxis=false, yAxis=true, Oy=-3](0,-3)(20,3)

\pstScalePoints(1e4,1e0){}{}
\listplot[linecolor=red,linewidth=1pt,showpoints=false]{\current}
\end{psgraph}
\end{pspicture}
\end{document}
share|improve this question

1 Answer 1

I do not really understand what you mean with linestyle. However here is a solution for a better label setting on the right:

\documentclass[a4paper,10pt]{article}
\usepackage{pstricks,pst-plot,pstricks-add}
\begin{document}

\begin{pspicture}(1,1)
\readdata{\voltage}{capv.txt}
\readdata{\current}{capi.txt}
\psset{llx=-1cm,lly=-1cm}
\psset{xAxisLabel={Time [ms]}, xAxisLabelPos={c,-0.3in}, yAxisLabel={Voltage [V]}, yAxisLabelPos={-0.3in,c}}

\begin{psgraph}[axesstyle=axes,xticksize=0 6,yticksize=0 20,
                subticks=0,Dx=5,Oy=-3](0,-3)(20,3){6cm}{3cm}
\pstScalePoints(1e4,1e0){}{}
\listplot[linecolor=blue,linewidth=1pt]{\voltage}
\multido{\iA=-3+1}{7}{\rput[r](21.75,\iA){$\iA$}}
\rput{90}(23,0){Current[A]}
\pstScalePoints(1e4,1e0){}{}
\listplot[linecolor=red,linewidth=1pt,xStart=1.e-8]{\current}
\end{psgraph}
\end{pspicture}
\end{document}

enter image description here

share|improve this answer

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.