Reputation: 618
I'm plotting 2 data sets via gnuplot. Values of the first one are from ~2 million to ~3 million. Values of the second are from 1000 to 2000.
After plotting from file and checking show variables all
GPVAL_Y2_MIN is set to the correct value, but GPVAL_Y2_MAX is wrong. Its weird that GPVAL_Y_MAX is also wrong, however if plotting only the first set I get a relatively good value.
I'd like to set different ranges for yrange and y2range, but I cannot tell the possible values in advance. Of course I would like to fill the output screen as much as possible.
How could I do that?
EDIT: added currently used code
#!/usr/bin/gnuplot
reset
# Get max and min value
plot 'test.dat' every ::1 using 3, '' every ::1 using 4
y1_max = GPVAL_Y_MAX;
y1_min = GPVAL_Y_MIN;
y2_max = GPVAL_Y2_MAX;
y2_min = GPVAL_Y2_MIN;
set terminal png size 1024, 768 #output format png
set format y "%.1s %c"
# show png in a window without save
set output '| display png:-'
set yrange [y1_min:y1_max]
set y2range [y2_min:y2_max]
plot 'test.dat' every ::1 using 3 lt rgb '#FF00FF' title "vsize" with line, \
'' every ::1 using 4 lt rgb '#FF0000' title "rss" with line axes x1y2
As you see, I'm plotting the data first to get min and max values and after that creating a terminal.
Upvotes: 0
Views: 209
Reputation: 310117
Without having a datafile to work with, my guess is that you're problem lies in the fact that in your first pass (where you collect the min/max values), you're plotting both data sets on the x1y1 axis. On your second pass, you plot column 4 on the x1y2 axis, but you never actually reset the y2 range from anything other than the default (which you hard-coded as opposed to autoscaling). In other words:
plot 'test.dat' every ::1 using 3, '' every ::1 using 4 axes x1y2
This brings up another question though -- Why aren't you just autoscaling?
set yrange [*:*]
set y2range [*:*]
Upvotes: 0