gnuplot print legend directly next to individual graphs - gnuplot

I want to project a 3D plot into a 2D plot. Assuming f(x,y) describes my 3D plot, I want to treat y as a parameter and simultaneously plot f(x,0), f(x,2), f(x,4), etc. in one 2D plot. Instead of going for different line/point styles and colors with a legend in a corner, I'd like to make each plot in the same style and place a label next to each individual line.
Is this even possible in gnuplot or would I have to fall back on something more complex?

I had a similar question recently. There is an option in the development version of gnuplot (4.7.0) that does this. You can change the position of line titles to be at the end/beginning of the line itself. If your plot looks like I imagine (sort of a contour plot) this may be what you want:
plot f(x,y) title 'f(x,y)' at end
Otherwise you may have to specify the labels and their positions manually:
help set label
for more info.

Related

plt.axvline labels exceeding limit of plot problem

full - clearest image, shows the labels extending out the right of my plot
"zoomed" - highlighting why this is a problem as the plot becomes unreadable when selecting and plotting subset of the x-axis range
I'm working on some data where I have plotted a spectrum and have added vertical lines to specific positions. I have labelled these lines but my problem is that if I want to "zoom in" by decreasing my x axis range, the full list of labels for the vertical lines are still plotted resulting in an unreadable plot.
I iterate through a list of x positions and labels for my vertical lines and plot as follows:
for x_pos, label in zip(list_x_pos, list_label):
plt.axvline(x=x_pos)
plt.text(x_pos, y, str(label), rotation=90)
plt.xlim(2, 5)
So, because my "x values" go > 5 the resulting plot is a tiny figure with a row of the labels extending out from it.
The only solution I can think of is to slice my list_x_pos but this will crate other problems for me so ideally looking to find a way to just show the labels within the range of the plot.
Hope I've made sense!
Thanks,
Olie
You can use plt.text(..., clip_on=True) to force texts outside of the box to not be displayed.
Resize the axes first and then plot the vertical line.

Gnuplot: 3D plot scattered data with color

How can I plot (many) uncorrelated points from a data file in 3D with color corresponding to the value of one column? The color-value is non-integral.
======================================================================
details:
I have a large data file with three columns of the form
longitude latitude color
The data is scattered and uncorrelated, i.e. no underlying grid and no relationship between the points (except that every coordinate appears only once). color is an arbitrary scalar. I know the min and the max value of that, and would like to have linear scaling of the color in between. Which colormap is not clear atm, a first step would be to produce any meaningful output.
How can I plot dots on the longitude-latitude coordinates on the unit sphere (i.e. radius = 1) with the specified color?
No interpolation is wanted, not even a connection between the points. (I'm also happy for suggestions how to do that in an easy way, but it's actually not important)
This is how far I've gone, but the coloring is missing:
set mapping spherical
splot 'the_file.data' u 1:2:(1)
Thanks a bunch!
You can use linecolor palette, which allows you to specify an additional column which is used to select the respective color from the current palette:
set mapping spherical
splot 'the_file.data' using 1:2:(1):3 linecolor palette

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

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.

How to make an horizontal box-and-whiskers plot in gnuplot

How do you make an horizontal box-and-whiskers plot in gnuplot? Similarly to this one:
Gnuplot can easily be used to produce vertical box-and-whiskers plots with the 'candlesticks' and 'whiskerbars' keywords, but I have not managed to find any example of an horizontal candlesticks/box-and-whiskers horizontal plot produced via gnuplot online.
Example of a vertical plot produced by gnuplot:
example of a vertical box-and-whiskers plot http://www.cise.ufl.edu/~dts/cop3530/proj02/candlesticks.6.png
Gnuplot generally doesn't switch directions well... for example you can't plot rows instead of columns, and it's hard to make histograms (or any other kind of plot) go horizontal instead of vertical.
People have made horizontal histograms, however, and you might be able to modify the code found at this site.

Resources