sgh
sgh

Reputation: 11

increasing yRange from negetive to positive in gnuplot

I want my yrange to be between -100 and 0, and here is my plot in gnuplot

I want the y axis to be from -100 increasing up to 0! what should I do?! BTW: My plot is histogram! when I set it to [-100:0] my plot is upside down, the bars are from up to down!!

set style data histogram
set yrange [-100:0]

set style fill solid 0.3
set bars front
plot 'mean.rssi' using 2:xticlabels(1) title columnheader

above is my code, histogram is plotted from 0 to -100, but I want to be from -100 to 0!

The file mean.rssi contains two columns, for example

Dlink -93

Upvotes: 0

Views: 924

Answers (2)

Christoph
Christoph

Reputation: 48390

That isn't directly supported, histograms always have their base line at 0, positive values give boxes oriented upwards, negative values downwards.

Since your range is known, you should convert the range [-100:0] to the range [0:100] and relabel the y-axis:

set style data histogram
set yrange [0:100]

set ytics ('-100' 0)
set for [i=-100:0:20] ytics add (sprintf('%d', i) i + 100)

plot 'mean.rssi' using ($2 + 100):xticlabels(1)

Other solutions would use the boxes plotting style. If you could use this depends on whether you need the stacking features of the histogram style.

Upvotes: 1

brm
brm

Reputation: 3806

You can specify ranges with square brackes. For example, to specify both X and Y ranges you could do:

plot [-20:20][-50:50] sin(x)

which would set the X-range to [-20,20] and the Y-range to [-50,50].

To only set the Y-range, you can set the X-range to the empty brackets [], e.g.

plot [][-50:50] sin(x)

To only set the X-range you can do something similar, or just omit the Y-range completely:

plot [-20:20] sin(x)

Upvotes: 0

Related Questions