Pyxplot

Examples - Conversion scales


Prev
Next

Download this example:

Using linked axes and Pyxplot's automatic conversion of physical units to create unit conversion scales

In this example, we use Pyxplot's automatic conversion of physical units to create conversion scales between various Imperial and metric units.

Script

# Generalised routine for making conversion scales
subroutine conversionScale(origin_x,origin_y,conversionFactor,unitA,unitB)
 {
  set size ratio 1e-2
  exec "set axis x2 linked x using x*%s"%(conversionFactor)
  set axis y invisible
  set xlabel unitA
  set x2label unitB
  set origin origin_x,origin_y
  plot
 }

set nodisplay
set multiplot
set width 9

# Make a temperature conversion scale
set xtics outward -10,10
set x2tics outward 20,20
set xrange[-10:100]
call conversionScale(0,0,"unit(oC)/unit(oF)",r"$^\circ$C",r"$^\circ$F")

# Make a mass conversion scale
set xtics outward 0,1
set x2tics outward 2,2
set xrange[0:10]
call conversionScale(0,3.2,"unit(kg)/unit(lb)","kg","lb")

# Make a length conversion scale
set xtics outward 0,2
set x2tics outward 1,1
set xrange[0:20]
call conversionScale(0,6.4,"unit(cm)/unit(in)","cm","in")

set display
refresh