0
votes

I am having a set of data (one column) available from my dropbox. In the dropbox, there is also a gnuplot code that produces the following figures.: Not normalized histogram for velocities and Not normalized distribution for the radius. What I would like to do are the following

  1. Normalize both histogram using gnuplot
  2. to make the radius graph as nice as the velocities and magnify both if possible.

I am facing this problem since a week since I am not used with histograms in gnuplot, so your help will be greatly appreciated. Here is the gnuplot code:

reset
set terminal pngcairo 
set output 'r_distr_3ev.png'
set key off
set border 3

set boxwidth 0.05 absolute
set style fill solid 1.0 noborder

bin_width = 0.005;

bin_number(x) = floor(x/bin_width)

rounded(x) = bin_width * ( bin_number(x) + 0.00025 )

plot 'data_prob_distr_funct_radius_3eV.dat' using (rounded($1)):(1) 
smooth frequency with boxes


reset
set terminal pngcairo 
set output 'v_distr_3ev.png'
set key off
set border 3

set boxwidth 0.05 absolute
set style fill solid 1.0 noborder

bin_width = 0.1;

bin_number(x) = floor(x/bin_width)

rounded(x) = bin_width * ( bin_number(x) + 0.5 )

plot 'data_prob_distr_funct_veloci_3eV.dat' using (rounded($3)):(1) 
smooth frequency with boxes

Here is a sample of data (file is too long to be posted fully). However, need to edit the data sources on the plot commands.

 # radius                        # Velocities
1.432710516747764062         0.518383911504932460
1.415400787912409752         0.117744310428800222
1.420463215076467778         0.083766261830559782
1.437922410272506557         0.309560054349534541
1.420463215076467778         0.268622745024368170
1.438756837417662471         0.203390900905284472
1.418356121124933145         0.518346867895466801
1.438756837417662471         0.182812150806309304
1.421657988632006209         0.299301056216330852
1.432074613018175180         0.293967535681474712
1.421657988632006209         0.183613746565735064
1.412588932829508259         0.501168210407462289
1.416512172894701438         0.179507944624779481
1.412588932829508259         0.029653108171494944
1.417995684224648612         0.234379565912604448
1.417914885270917580         0.255589209064060963
1.417995684224648612         0.539792616529789826
1.408834060670934862         0.256331796703176962
1.423042784959195561         0.082132902455306064
1.408834060670934862         0.198595146234998993
1.432298354037856436         0.255681807316227472
1.406168218647184665         0.595524682621352608
1.432298354037856436         0.150127810412636647
1.431591815111461719         0.271379130577297567
1.422276604689641788         0.367863070449541862
1.431591815111461719         0.135432525011420862
1.431551259009345989         0.138525547190355175
1.400408991855918162         0.626963309755715237
1.431551259009345989         0.294435076616490321
1.425580611910310047         0.527847978352356417

Cheers

1
Could you please post your gnuplot code here? I rather not download it. I know of a way to produce normalized histograms; but want to make sure it is consistent with how you want to do it. Also, please post your data as well. - Ptheguy
I did some upgrades on the thread just now. - many
Did the answer help? - Ptheguy
Sorry, I was so busy these last days. I did not get the time to deal with this thread. Yes It helps. It is a good basis for me to improve my code. Many thanks - many

1 Answers

0
votes

To get normalized histograms, you need to increment the count for each data point in proportion. This translates to this:

plot 'file.dat' u (rounded($1)):(1./(sum*bin_width)) smooth freq w boxes

where sum is the number of data entries. If you do not know sum already from your program, then you can get it like this:

stats file.dat
sum=floor(STATS_records/100.)

To get the two histograms to look the same (nice), set boxwidth and bin_width to the same value.