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.

This question is related to psgraph with y-axis on left and right of graph and axis labels but can stand alone, as it is really about loops and variables.

I'm really sad that I have to ask this question, I am clearly incompetent.

In the following code can I replace the set of 13 consecutive \rput commands (near to the bottom) with \multido{...}?

The objective is to have a different scale on the right axis to that on the left. I have managed this, but the code is so inelegant there must be a proper way. It seems like you ought to be able to \def\anumber{lowest y axis value string } and then do some simple arithmetic on it inside a \multido to place the desired text in the desired locations.

\begin{pspicture}(1.2,1)

\readdata{\vin}{largesignalvin.txt}
\readdata{\vout}{largesignalvout.txt}
\readdata{\idone}{largesignalID1.txt}
\readdata{\idtwo}{largesignalID2.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 12, yticksize=0 5, subticks=0, Dx=0.5, Oy=-6](0,-6)(5,6){7cm}{5cm}

\pstScalePoints(1e3,1e0){}{}

\listplot[linecolor=blue,linewidth=2pt]{\vin}
\listplot[linecolor=black,linewidth=2pt]{\vout}

\rput[r](5.58,-6){$-1.2$}
\rput[r](5.58,-5){$-1.0$}
\rput[r](5.58,-4){$-0.8$}
\rput[r](5.58,-3){$-0.6$}
\rput[r](5.58,-2){$-0.4$}
\rput[r](5.58,-1){$0.2$}
\rput[r](5.58,-0){$0.0$}
\rput[r](5.58,1){$0.2$}
\rput[r](5.58,2){$0.4$}
\rput[r](5.58,3){$0.6$}
\rput[r](5.58,4){$0.8$}
\rput[r](5.58,5){$1.0$}
\rput[r](5.58,6){$1.2$}

\rput{90}(5.85,0){Current[$\mu$A]}

\pstScalePoints(1e3,5e3){}{}
\listplot[linecolor=red,linewidth=2pt]{\idone}
\listplot[linecolor=green,linewidth=2pt]{\idtwo}

\end{psgraph}

\end{pspicture}

The data files, should they be needed, are available from http://www.iceamplifiers.co.uk/latex/[insert_name_of_file].txt

share|improve this question
add comment

1 Answer

no need for \multido. Use a second axis:

\documentclass{scrartcl}
\usepackage{pst-plot}
\begin{document}

\readdata{\vin}{largesignalvin.txt}
\readdata{\vout}{largesignalvout.txt}
\readdata{\idone}{largesignalID1.txt}
\readdata{\idtwo}{largesignalID2.txt}

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

\begin{psgraph}[axesstyle=axes,xticksize=0 12,yticksize=0 5,subticks=0,Dx=0.5,Oy=-6](0,-6)(5,6){7cm}{5cm}
\pstScalePoints(1e3,1e0){}{}
\psaxes[xAxis=false,Dy=0.2,dy=1,ticks=none,axesstyle=none](5.9,0)(5.9,-6)(5.9,6)
\listplot[linecolor=blue,linewidth=2pt]{\vin}
\listplot[linecolor=black,linewidth=2pt]{\vout}
\rput{90}(5.9,0){Current[$\mu$A]}

\pstScalePoints(1e3,5e3){}{}
\listplot[linecolor=red,linewidth=2pt]{\idone}
\listplot[linecolor=green,linewidth=2pt]{\idtwo}

\end{psgraph}

\end{document}

enter image description here

share|improve this answer
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.