Moataz Elmasry
Moataz Elmasry

Reputation: 2519

gnuplot histogram does not visualize small numbers

I'm just taking the first look at gnuplot today and using the histogram example, I wanted to build a small example as from the tutorial, only I changed the input numbers from 50,000 something to 100-range and it is not visualized correctly. Here's the dat file

Region   Denmark   Netherlands     Norway  Sweden    
1891-1900       500  400  300   200 

And this is the gnuplot script

set terminal pngcairo
set output 'histograms.2.png'
set boxwidth 0.9 absolute
set style fill   solid 1.00 border lt -1
set key inside right top vertical Right noreverse noenhanced autotitles nobox
set style histogram clustered gap 5 title  offset character 0, 0, 0
set datafile missing '-'
set style data histograms
set xtics border in scale 0,0 nomirror rotate by -45  offset character 0, 0, 0
set xtics  norangelimit font ",8"
set xtics   ()
set title "US immigration from Northern Europe\n(same plot with larger gap between clusters)" 
set yrange [ 0.00000 : 3000. ] noreverse nowriteback
i = 22
plot 'immigration.dat' using 1:xtic(1) ti col, '' u 2 ti col, '' u 3 ti col, '' u 4 ti col

As seen in here:

enter image description here

the first column is wrongly visualized. any ideas?!

Upvotes: 0

Views: 438

Answers (1)

mgilson
mgilson

Reputation: 310069

I think you want:

plot 'immigration.dat' using 2:xtic(1) ti col, '' u 3 ti col, '' u 4 ti col, '' u 5 ti col

In your version, gnuplot is interpreting the data in the first column (1891-1900) as a number (1891). You can also see this by carefully looking at the key -- The red bar corresponds to Region.

Upvotes: 1

Related Questions