How to build several y-axes?

I saw this graph, and only for the sake of curiosity it was interesting whether it is possible to build a figure with several y-axes, as in the figure enter image description here

Many thanks!

+5
source share
2 answers

As andyras wrote, you can use the second y axis if you have only two data sets. In this case, you also need

set ytics nomirror # remove the tickmarks of the left ayis on the right side set y2tics # make the right y-axis 'visible' 

If you want to build more than one dataset, I would suggest using multiplot . You can overlay several independent graphs and place a unique y-axis offset for each of them. However, you need to make sure that the number of y-tics and y-tick positions is the same.

Plot:

enter image description here

(I don't need a key here, it still needs to be configured)

The code:

 set multiplot set xrange[0:10] # We need place to the left, so make the left margin 30% of screen set lmargin screen 0.3 ##### first plot set ytics 0.4 set yrange[-1.2:1.2] set ylabel "Voltage" textcolor rgb "red" plot sin(x) ##### Second plot set ytics 1 set yrange[-3:3] set ytics offset -8, 0 set ylabel "Current" offset -8, 0 textcolor rgb "green" plot 3*cos(x) linecolor 2 ##### Third plot set ytics 0.5 set yrange[-1.5:1.5] set ytics offset -16, 0 set ylabel "Power" offset -16, 0 textcolor rgb "blue" plot 3*sin(x)*cos(x) linecolor 3 unset multiplot 
+4
source

Yes, you can have two y axes for free, for example

 plot x, x**2 axes x1y2 

The axes x1y1 allows things to be placed on x1y1 , x2y1 , etc. If you want more than two things to be built on the same y-axes, you must normalize things yourself:

 plot 'data1.dat' using 1:($2/MAX_1), \ 'data2.dat' using 1:($2/MAX_2), \ 'data3.dat' using 1:($s/MAX_3) 

MAX_X variables can be pre-calculated using the stats command in gnuplot 4.6+, or you can put them manually.

+2
source

Source: https://habr.com/ru/post/1208697/


All Articles