Often it may be desired that multiple axes on a graph share a common range, or be related to one another by some algebraic expression. For example, a plot with wavelength of light as one axis may usefully also have parallel axes showing frequency of light
or photon energy
. The following example sets the x2 axis to share a common range with the x axis:
set axis x2 linked x
An algebraic relationship between two axes may be set by stating the algebraic relationship after the keyword using, as in the following example which implement the formulae shown above for the frequency and energy of photons of light as a function of their wavelength:
set xrange [200*unit(nm):unit(800*nm)] set axis x2 linked x1 using phy_c/x set axis x3 linked x2 using phy_h*x
As in the set xformat command, a dummy variable of x, y or z is used in the linkage expression depending upon the direction of the axis being linked to, but a dummy variable of x is still used when linking to, for example, the x2 axis.
As these examples demonstrate, the functions used to link axes need not be linear. In fact, axes with any arbitrary mapping between position and value can be produced by linked in a non-linear fashion to another linear axis, which, if desired, can then be hidden using the set axis invisible command. Multi-valued mappings are also permitted. Any data plotted against the following x2-axis for a suitable range of x-axis
set axis x2 linked x1 using x**2
would appear twice, symmetrically on either side of .
Insofar as is possible, linked axes autoscale intelligently when no range is set. Thus, if the x2-axis is linked to the x-axis, and no range to set for the x-axis, the x-axis will autoscale to include all of the data plotted against both itself and the x2-axis. Similarly, if the x2-axis is linked to the x-axis by means of some algebraic expression, the x-axis will attempt to autoscale to include the data plotted against the x2-axis, though in some cases – especially with non-monotonic linking functions – this may prove too difficult. Where PyXPlot detects that it has failed, a warning is issued recommending that a hard range be set for – in this example – the x-axis.
A plot of many blackbodies demonstrating the use of linked axes.
In this example we produce a plot of blackbody spectra for five different temperatures
which is evaluated in PyXPlot by the system-defined mathematical function Bv(nu,T). We use the axis linkage commands listed as an example in the text of Section 1.8.9 to produce three parallel horizontal axes showing wavelength of light, frequency of light and photon energy. |
||||
set numeric display latex |
||||
bb(wlen,T) = Bv(phy_c/wlen,T) |
||||
plot bb(x, 30) title "$T= 30$ |
||||
![]() |
A plot of the temperature of the CMBR as a function of redshift demonstrating non-linear axis linkage.