Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Histogram plot

94 views
Skip to first unread message

Gurpreet Kaur

unread,
Dec 10, 2012, 11:21:10 AM12/10/12
to
Hi all,

I am trying to make a histogram with 2 columns from a big text file using gnuplot, but getting errors. Please suggest.

Thanks

Hans-Bernhard Bröker

unread,
Dec 10, 2012, 6:18:15 PM12/10/12
to
On 10.12.2012 17:21, Gurpreet Kaur wrote:

> I am trying to make a histogram with 2 columns from a big text file
> using gnuplot, but getting errors. Please suggest.

How do you suppose anybody could make a meaningful suggestion if you
don't show _any_ of the relevant facts: no commands, no input, no
output, not even the actual errors you get?

Gurpreet Kaur

unread,
Dec 10, 2012, 7:49:24 PM12/10/12
to
Hi,
I am a beginner in Gnuplot and used following code for drawing histogram from two columns in text file, but histogram does not show in negative Y-axis.
n=100 #number of intervals
max=16000 #max value
min=-300 #min value
width=(max-min)/n #interval width
hist(x,width)=width*floor(x/width)+width/2.0 #function used to map a value to the intervals
#set term png #output terminal and file
#set output "histogram.png"
set xrange [min:max]
set yrange [0:]
#to put an empty boundary around the
#data inside an autoscaled graph.
set offset graph 0.05,0.05,0.05,0.0
set xtics min,(max-min)/5,max
set boxwidth width*0.9
set style fill solid 0.5 #fillstyle
set tics out nomirror
set xlabel "avePot"
set ylabel "Frequency"
#count and plot
plot "ave.txt" u (hist($1,width)):(0.5) smooth freq w boxes lc rgb"red"

Thanks

scil...@gmail.com

unread,
Dec 10, 2012, 11:10:13 PM12/10/12
to
> set yrange [0:]

This line explicitly sets your y-range to be from 0 to whatever. Remove it if you want gnuplot to automatically adjust y-range or change [0:] to correct interval.

gkaur

unread,
Dec 11, 2012, 11:53:02 AM12/11/12
to
On Monday, December 10, 2012 11:10:13 PM UTC-5, scil...@gmail.com wrote:
> > set yrange [0:]
>
>
>
> This line explicitly sets your y-range to be from 0 to whatever. Remove it if you want gnuplot to automatically adjust y-range or change [0:] to correct interval.


Hi, I tried this option, but still not getting

Hans-Bernhard Bröker

unread,
Dec 11, 2012, 2:42:52 PM12/11/12
to
On 11.12.2012 01:49, Gurpreet Kaur wrote:
> On Monday, December 10, 2012 6:18:15 PM UTC-5, Hans-Bernhard Bröker
> wrote:

>> How do you suppose anybody could make a meaningful suggestion if
>> you don't show _any_ of the relevant facts: no commands, no input,
>> no output, not even the actual errors you get?

> I am a beginner in Gnuplot and used following code for drawing
> histogram from two columns in text file, but histogram does not show
> in negative Y-axis.

A proper histogram does not have negative values. And you promised
yours wouldn't either:

> set yrange [0:]

So why do you expect the result of counting things ("smooth freq") to
turn out negative?
0 new messages