'Mapping y2 axis using y axis and x axis in Gnuplot
My data file is given below
T(K) G(T) K
500.00 53235.1 2.7460E-06
510.00 52213.4 4.4915E-06
520.00 51193.2 7.2062E-06
530.00 50174.7 1.1353E-05
540.00 49157.8 1.7581E-05
550.00 48142.4 2.6787E-05
560.00 47128.7 4.0191E-05
570.00 46116.5 5.9429E-05
580.00 45105.9 8.6672E-05
590.00 44096.8 1.2476E-04
600.00 43089.2 1.7736E-04
610.00 42083.1 2.4917E-04
620.00 41078.5 3.4614E-04
630.00 40075.3 4.7572E-04
640.00 39073.5 6.4719E-04
650.00 38073.1 8.7193E-04
660.00 37074.1 1.1639E-03
670.00 36076.5 1.5398E-03
680.00 35080.1 2.0201E-03
690.00 34085.1 2.6287E-03
700.00 33091.4 3.3943E-03
The first column is temperature (Kelvin), second column is Gibbs energy (J) and third column is equilibrium constant. Third column is related to second column as K=exp(-G/RT).
I need a plot of T(K) vs. G(T) (y-axis) and T(K) vs. K (y2-axis). We can use the set link command as
set link y2 via exp(-y/(8.31452*($1))) inverse -log(y)*8.31452*($1)
where $1 refers to temperature (first column). We can then use the command
plot 'data.dat' u 1:2 w l ls 1 title "Gibbs energy'
to plot the data. Is the use of $1 (first column) in the set link command correct?
Question modified after response of @Ethan
The third column was given only as a reference. I wish to plot y2 (in logscale) by linking y (linear scale) so that there is 1:1 correspondence of each tick in y to that in y2. Intention is to link axis showing the Gibbs energy with that of another axis that automatically calculates the equilibrium constant using the above relation and plots it in logscale
Solution 1:[1]
No. The only variable in the "set link y2" command should be "y".
I think you slightly misunderstand the idea of the link command. It describes a fixed relationship between y1 and y2. If y1 and y2 are related by some function of T then that relationship is "fixed" only for some particular fixed value of T.
From your description you want a plot command like
set datafile columnhead
set tics nomirror
set y2tics
set key top center horizontal
set xlabel "Temperature"
plot 'data.dat' using 1:2 axes x1y1 title "Gibbs energy", \
'data.dat' using 1:3 axes x1y2 title "K(T)"
But the y1 and y2 axes are not linked here. You will get two distinct plot lines exactly because they are not linked. If I have misunderstood your intent, please modify the question to clarify what you want to plot.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ethan |

