title: Gnuplot: how to add y2 axis scale for different units
body: <p>I'm plotting data from a file. The data points are in metric units. I want to show a second scale on the right (y2) that's in standard units.</p>
  
  <p>The file represents rocket motor thrust over time. The data are in Newtons. I want to show newtons on the left (this happens by itself, naturally) and pounds force on the right. The conversion is a simple factor (multiply N by 0.2248 to obtain lbf).</p>
  
  <p>I can set y2tics and if I set y2range manually, they appear on the right. What I don't know how to do is set y2range automatically to y1range * a factor.</p>
  
  <p>My eventual solution is to plot twice, once in Newtons on y1 and once in pounds on y2, and make the y2 plot almost invisible:</p>
  
  <pre><code>plot '-' using 1:($2*0.2248) with dots axes x1y2 lc rgb 'white' notitle, \
        '' using 1:2 with lines lc rgb '&lt;color&gt;' title '&lt;title&gt;'
  </code></pre>
  
  <hr>
  
  <p>The solution above often generates slightly different y scales: with autoragne, gnuplot rounds up the range so the top tick on each axis is a round number, and of course the rounding is different for different units.</p>
  
  <p>Ultimately I end up with Python code that finds the highest thrust value in each graph, then I explicitly set yrange to that number and y2range to that number * 0.2248:</p>
  
  <pre><code>f.write("set yrange [0:%s]; set y2range[0:%s]\n" % (peak_thrust, peak_thrust*NEWTON_LBF));
  </code></pre>
  
  <p>Here's the end result: <a href="http://www.lib.aero/hosted/motors/cesaroni_12-15-12.html" rel="noreferrer">http://www.lib.aero/hosted/motors/cesaroni_12-15-12.html</a> (sample graph below)
  <img src="https://i.stack.imgur.com/ROFCo.png" alt="enter image description here"></p>