Histogram in gnuplot - bins not separated one from another - gnuplot

Sorry for my English,
I would like to make a histogram in gnuplot, where bins are not separated one from another by vertical lines, something like it is shown in the following figure:
I usually use "plot [...] with boxes" command to make a histogram, but it leads to a histogram with such vertical lines, which make the histogram unclear for bigger number of bins in the plot.
My data consists of two values for every value of x.

My comment again as answer, according to the StackOverflow "rule": no answers in comments...
You are probably looking for:
plot ... with steps
Check help steps. You may also want to check this answer about steps.

Related

how to concatenate two histograms in python

The highlighted part is the one I am having problem with. I have imported numpy in python to make two histograms of image pixels. But cannot clearly figure out how to concatenate both the histograms together into one histogram?
I am not exactly sure what you mean by concatenate. I'm assuming you want multiple histograms side-by-side. If this is the case, your questions has already been answered here: Plot two histograms at the same time with matplotlib

Gnuplot - Plot data on another abscissa by interpolation

Good evening,
I have a problem with Gnuplot. I tried to sum up my problem to make the comprehension easier.
What I have : 2 sets of data, the first one is my experimental data, about 20 points, the second one is my numerical data, about 300 points. But the two sets don't have the same abscissa.
What I want to have : I want my numerical data be interpolate on the x-experimental abscissa.
I know it is possible to do that with Xmgrace (paragraph Interpolation at http://plasma-gate.weizmann.ac.il/Xmgr/doc/trans.html#interp) but with Gnuplot ?
What I want to have in addition : is it possible, then, to subtract the y-experimental data of my y-numerical data at the x-experimental abscissa points ?
Thank you in advance for your answer,
zackalucard
You cannot interpolate the ordinate values of one set to the abscissa values of the other. gnuplot has no mechanism for that.
You can however plot both datasets using one of the smoothing algorithms (check "help smooth") with common abscissa values (which might (be made to) coincide with the original values of one set.)
set table "data1.tmp"
plot dataf1 smooth cspline
set xrange [GPVAL_x_min:GPVAL_X_max] # fix xrange settings
set table "data2.tmp"
plot dataf2 smooth cspline
unset table
Now you have the interpolated data in two temporary files, and only need to combine them into one:
system("paste data1.tmp data2.tmp > correlation.dat") # unixoid "paste" command
plot "correlation.dat" using 2:4
(If you have a sensible fit function for both datasets, the whole thing becomes much easier : plot dataf1 using (fit1($1)):(fit2($1)))
You can use smoothing, this should do the trick
plot "DATA" smooth csplines
(csplines is just one options, there others, e.g. bezier)
But I don't think you can automatically determine the intersection of the smoothed curved. You use the mouse to determine the intersection visually, or alternatively fit some functions f(x) and g(x) to your curves and solve f(x)=g(x) analytically

2D plot in python

I have 3 sets of data x,y,z where z represents the scan steps and z=50. Corresponding to z I have a each values of x and y. I want to plot a line or contour plot at 5th, 10th and 20th scan steps. Is it possible and which function should I use?
I don't fully understand how your data is organized, but Matplotlib is the easiest way to pop up a contour plot: see this for example:
http://matplotlib.org/examples/pylab_examples/contour_label_demo.html
If you remove the last past of that URL, you can browse the entire gallery for more examples, some of which may be closer to what you are try to do.
A more involved and more powerful alternative would be Chaco. You can refer to this example:
http://docs.enthought.com/chaco/user_manual/annotated_examples.html#contour-plot-py
Mayavi is for 3D plotting which doesn't seem to be what you are trying to do. If you are curious, checkout:
http://docs.enthought.com/mayavi/mayavi/
Hope this helps.

Draw axis thru x=0 and y=0

I have a set of data that I'm plotting as a scatter graph which has both positive and negative values on both axis. When I plot this in Flot, the axis are draw at the bottom and the left by default. Is there a way to make it draw the axis through the center of the graph? #X=0 and Y=0?
In other words, instead of this:
I want something like this:
That isn't possible in the default flot. I'm sure it could be hacked in if you wanted to dig into the source, but flot by itself only supports left/right for the y-axis, and top/bottom for the x-axis.
In case anybody else comes across the same need, I created a plugin for Flot and put it here:
https://github.com/burlandm/Flot-Origin-Axis
It does what I need, but I won't make any promises that it'll fit your particular scenario. If I have time, I might try and update it to cover more scenarios.

gnuplot: display only the roots

Gnuplot, a great package ... I'm in love with it. But we can have our tiffs as well, as any couple :-)
This time, I wanted to simply plot the roots of an equation: say a quadratic to keep things simple. However, I only want two nice round dots appearing on the x-axis representing the point where the quadratic crosses the x-axis or y=0 axis. In other words the roots (when they are real that is).
I don't want to do this with datafile ... I want gnuplot to calculate the roots and plot them.
First off, my attempts: single points aren't really what gnuplot would have you plot, it likes a good wide range of values. Preferably filling up the whole width of your canvas.
It's possible to locate a rectangle at a certain coordinate on your plot, but I wanted a round point. Currently I'm chasing up how to do a tiny filled polygon at that point. I have tried the "samples" option bu it doesn't seem useful.
Also though about defining a dirac-delta function so that only one point would be highlighted (though two would be needed).
ANy suggestions welcome, thanks.
there is a way, but it takes just a little bit of fiddling
narrowness=1
set yrange [0:10]
set xrange [-10:10]
poly(x)=(x**2+3*x-2)
roots(x) =floor(narrowness*poly(x))?1/0:0
plot roots(x) w points pt 7
depending on the function and the range you will need to set the width differently. if you see too many circles increase the narrowness, if you see too few (aka. none) decrease the narrowness
Cheers!
/B2S
oh, and PS. to increase accuracy set samples to some higher value
And Alternatively if you happen to already know the roots, say r1(2,0) and r2(-1,0) then you can plot them using
plot '-' with points pt 7
2 0
-1 0
e
Not sure if this really helps, but if you can define a custom function to calculate the roots, gnuplot will display it.

Resources