Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
508 views
in Technique[技术] by (71.8m points)

gnuplot - Why do I have a problem with the two axes on the right when I use the multi-axis function?

I am having a series of problems when defining the axes in my graphic and I would like to share it with you to see if among all we can find the error

I have found on this website a user who has made it similar. My idea is to have one axis on the left and two on the right. But for some reason, it's probably silly, it does not appear correctly.

My code is as following:

set terminal postscript eps enhanced color "Times-Roman" 15
set output "TC_8.eps"
set multiplot
set xlabel "Temperature/{/Symbol 260} C"
set xrange [0:1500]
set key off
set autoscale  y
set autoscale y2


##### first plot


set yrange[0:15]
set ylabel "Thermal Diffusivity/(mm^2/s)" textcolor rgb "red"
plot "dt8.txt" using 1:2 smooth cspline lc rgbcolor "red"


##### Second plot

set y2range[0:40]
set y2tics nomirror
set y2label "Thermal Conductivity/ (W/m K))" offset 8, 0 textcolor rgb "green"

plot "dt8.txt" using 1:4 axes x1y2 smooth cspline lc rgbcolor "green"

##### Third plot

set y2range[0:2]
set y2tics no mirror
set y2label "Specific Heat/ (J/(g K))" offset 16, 0 textcolor rgb "blue"
plot "dt8.txt" using 1:3 axes x1y2 smooth cspline lc rgbcolor "blue"

unset multiplot

and the data series is very simple

20 11.466 0.733 28.894
499.6 6.338 1.119 24.38
998.9 5.3 1.292 23.542
1499 4.639 1.645 26.247

The problem is that the two axes on the right do not appear correctly, and the data lines ... either.

Thanks in advance

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Do not hesitate to append your plot result and give the reference where you have found something similar.

One way might be to change the margins of the graph and plot another dummy graph just for the third (separated) axis. By the way, you can put two datalines into one plot.

Code: (edit: modified to make it copy&paste including data)

### 3 y-axes
reset session

$Data <<EOD
 20     11.466  0.733  28.894
 499.6   6.338  1.119  24.38
 998.9   5.3    1.292  23.542
1499     4.639  1.645  26.247
EOD

set key off
set autoscale  y
set autoscale y2

set lmargin 10
set tmargin 2
set bmargin 4
set rmargin 20

set multiplot

    ##### first plot
    set xlabel "Temperature / {/Symbol 260}C" font ",11"
    set xrange [0:1500]

    set ylabel "Thermal Diffusivity / (mm^2/s)" textcolor rgb "red" font ",11"
    set yrange[0:16]
    set ytics nomirror

    set y2range[0:40]
    set y2tics nomirror
    set y2label "Thermal Conductivity / (W/m K)" offset -1,0 textcolor rgb "green" font ",11"
    set grid xtics, ytics
    
    plot $Data u 1:2 axes x1y1 smooth cspline lc rgbcolor "red", 
            '' u 1:4 axes x1y2 smooth cspline lc rgbcolor "green"

    ##### Second plot
    unset xlabel 
    unset ylabel
    unset y2label
    unset tics

    set y2range[0:2]
    plot $Data u 1:3 axes x1y2 smooth cspline lc rgbcolor "blue" 

    ##### Third plot
    set rmargin 10
    set border 8     # only right border visible
    set y2label "Specific Heat/ (J/(g K)" offset -1,0 textcolor rgb "blue" font ",11"
    set y2tics nomirror offset 0,0
    plot NaN    # plot nothing

unset multiplot
### end of code

Result:

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...