Skip to content
Advertisement

Manual scaling of axis (poltting with boxes) in gnuplot

I’m trying to plot a really long list, which represents frequency of some data. The x axis goes from 1 to 1881, and the y goes from 1 to 1978. I tried plotting with the following configurations:

set log y 5
set log x 32
set xtics 2
set ytics 5
plot "freq.dat" w boxes

But i get the following result: enter image description here

Which is clearly not good because there are these intersections of the boxes. I want to have some kind of scale that have a lot more space between 10 and 150 than the outside of this area. How can i do that? I’ve tried every combination of logs and xtics and couldn’t make it look good. The y axis seems good to me, the only problem is the spacing of x-axis. Also, i want to know how to do this in gnuplot specifically (if possible). Thanks.

Advertisement

Answer

It seems to me that your script overrides somewhere the default boxwidth. The default behavior is:

By default, adjacent boxes are extended in width until they touch each other. A different default width may be specified using the set boxwidth command. Relative widths are interpreted as being a fraction of this default width.

So for example this:

set terminal pngcairo enhanced
set output 'fig.png'

set log x 2
set log y 5

set yr [0.2:3125]
set xr [1:512]

set boxwidth 1 relative

set xtics 1,2,512 out nomirror
set ytics 1,5,3125 out nomirror

unset key

#set style fill pattern 6
plot 'freq.dat' w boxes lc rgb 'royalblue' lw 1.1

then yields: enter image description here

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement