Draw boundary on colormap in Gnuplot using second data file - gnuplot

I have an ASCII data file (density.dat) in the format (x y D), where D represents a density-value at the point (x,y), from which I create a colormap:
set pm3d interpolate 2,2 corners2color mean
set view map
splot data_file u (1e9*$1):(1e9*$2):3 with pm3d
I have a second data file (potential.dat) with the same format (x y P), where P represents a potential value which can only have one of two values zero or 1.0 (say). I would like to indicate the boundary between the (three) regions (a straight line with slight perturbations) where the potential is zero and the regions where it is non-zero and overlay it on the first colormap of the density.
I though the approach where I plot the contours from one file on the plot of another file (similar to here), could work but the exported data using the 'set table filename' cannot be used for 'plot filename with image' it seems.
I would greatly appreciate ideas (or solutions..) to tackle this problem.
======== EDIT ==========
Working solution for me:
set contour base
set cntrparam level discrete 1.0
splot density_file u 1:2:3 with pm3d nocontour,\
potential_file u 1:2:3 w l nosurface

In the link you give, with image is used to plot the colour map, not the isolines, these are plotted with lines. I am not sure why you need to go through a table at all, it seems that you can handle everything with splot commands, unless you want to make fancy customisations or have strong constraints with margin control. See the discussion at the top of the post
http://gnuplot-tricks.blogspot.co.uk/2009/07/maps-contour-plots-with-labels.html
You will need to give more details in your post if you want a more precise answer.

Related

Default weighing criterion for gnuplot's 'lc palette'

I'm a novice in Gnuplot. Today I was plotting a simple txt file with two data columns, being the x and y coordinates of a cloud of points in the xy plane; I wanted to color them according to the position they occupied in the list, so I should have gone for something like:
plot "data.txt" u 1:2:0 lc palette
that produces what I want:
(desired plot)
By mistake, I omitted the "using" part of the command, so that I prompted:
plot "data.txt" lc palette
Now, the points still are plotted in the correct positions, so that gnuplot is automatically interpreting them as (x,y) coordinates... but the colors look like this:
(strangely colored plot)
I find this baffling since there's the possibility that I'm involuntarily highlighting some interesting feature of my data (which, by the way, consists of few iterations of a discrete recurrence for a set - the x=1.57 line you can see - of different initial conditions.
The question is: what criterion does 'lc palette' use to assign the parity I see to my points? What is its default behavior supposed to be in this case?
Thanks in advance!
EDIT: I don't know if it can be useful, but prompting 'show palette' I get:
palette is COLOR
rgb color mapping by rgbformulae are 7,5,15
figure is POSITIVE
all color formulae ARE NOT written into output postscript file
allocating ALL remaining color positions for discrete palette terminals
Color-Model: RGB
gamma is 1.5

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 - how can I get a figure with no point on it ? (I want to have only the axes, the title and the x- and y- labels)

I have to create a video presenting the evolution of some quantities as functions of time. I am creating images with gnuplot and I assemble them to make a movie. I am getting trouble generating the two first images: the first image is supposed to have no point on it (it is supposed to show only the title of the graph, the x and y axes and the labels of the axes) and the second one is supposed to have one single point on it.
Is it possible to create a graph containing no data on it with gnuplot?
Is it possible to create a graph containing one single point with gnuplot using an input file? The input file contains:
0 15
Thank you in advance for your answers,
Julien
To plot an empty graph, just plot a completely undefined function like
plot NaN
The main issue here is, that the autoscaling fails since there are no valid points. You must give a fixed xrange and yrange to get a plot:
set xrange [0:1]
set yrange [0:1]
plot NaN notitle
Plotting a single point works fine using
plot 'file.dat' using 1:2 with points
You'll get warnings saying Warning: empty x range [0:0], adjusting to [-1:1] and Warning: empty y range [15:15], adjusting to [14.85:15.15], but you get a plot. To remove the warnings, you must again provide a fixed xrange and yrange.

How to add custom label to Gnuplot graph legend?

In a graph I'm making with gnuplot I draw some grey lines (set arrow command), which represent the physical boundaries of my experiment (i.e., walls)
I would like to know how I can add this information on the legend of the graph, so it says "Walls" and have a grey line next to it.
I thought about creating a new series that contained this information, but I was wondering if it's possible to explicitly add it.
You can't add information directly to the legend. You can, however, either draw the legend explicitly, or plot a line which will not appear within the range of the plot, e.g.
plot [][0:1] 2 lc rgb 'gray' t 'Walls'
Or, if your x and y limits are already set:
...
[set x and y limits here]
...
plot 1e20 lc rgb 'gray' t 'Walls'
Just wanted to note: since plotting a single line tended to mess up a graph of mine, a better solution for me was to plot a single point; but as found in Plotting single points « Gnuplotting, that is kinda difficult (especially if insertion at arbitrary plot legend/key position is needed) - unless redirection is used... This is what worked for me:
plot "filename" using 1:8 \
,\
... # more plot lines here
,\
"<echo '-1 -1'" lc rgb 'white' with points title '---' \
,\
... # more plot lines here
One simple way is to make the name of the data file the legend which you want and then plot that data file.

Plot two datasets on the same graph with gnuplot. One with dgrid3d, the other one without

I'm trying to plot two data sets with gnuplot. They are both (x, y, z) triplets. They are not arranged on a grid. I want to plot one of them using dgrid3d and pm3d. On top of that I want to overlay the other data set but as just scattered points.
To give a more concrete example: I am trying to plot the effect of a cylinder approaching a surface. I want to plot the response of the surface and that's where dgrid3d comes in handy. On top of that, I want to plot the position of the cylinder and I have its circumference as points.
I used:
set dgrid3d 100,100,4
set pm3d
splot "dataset1" with pm3d, "dataset2" with dots
The data set has about 100x100 points, arranged on a near-square, so 100,100 works best here. No matter how I plot the second data set, it always ends up being a square of the same dimensions as the cylinder, instead of a nice circle. When I turn dgrid3d off, I can plot the second data set on its own and the result is a nice circumference of the cylinder.
So my question is: is it possible to plot a 3D graph using two data sets, one using dgrid3d and the other one not using it?
Yes, this is possible, but it is a little more tricky than you might think. The key is to use set table
For your example:
set dgrid3d 100,100,4
set pm3d explicit
set table "interpolated_data.dat"
splot "dataset1" with pm3d #writes the interpolated data to "interpolated_data.dat"
unset table
unset dgrid3d
splot "interpolated_data.dat" with pm3d, "dataset2" with dots
The reason that your attempt didn't work is because when dgrid3d is in effect, All data read in is interpolated to a grid and then plotted using whatever style you specify.
From gnuplot's help dgrid3d
When enabled, 3D data read from a file
are always treated as a scattered data set.
As a side note, this method can also be used to plot contours on top of a pm3d as well.

Resources