Gnuplot plane curve - gnuplot

I have a plane and a line in the XYZ coordinate system. The line is crossing the plane at some point through my view angle. So that the line is on one point of the diagram below the plane and at some other points above the plane. However in my current perspective the line is always visible although it is below the plane and should be therefore not visible. Does any command exist how to make this way of displaying possible?

Yes, you can use the hidden3d option for hiding the respective line parts behind the surface:
set ticslevel 0
set hidden3d
set view 40,50
set isosamples 30
splot x+y, "-" with lines
10 10 -10
0 0 10
e
This gives (with 4.6.4):
For this solution you need a data file (or the inline data as specified above), to define your line. Don't know, if another variant is possible.
Also, what I noted is, that the surface grid is drawn above the line. I haven't found a way to change that. I'll investigate on that, maybe its a bug.

Related

Plotting smooth sphere from discrete data with gnuplot

I have data generated from python code as such:
u, v = np.mgrid[0:2*np.pi:180*1j, 0:np.pi:90*1j]
X = np.cos(u)*np.sin(v)
Y = np.sin(u)*np.sin(v)
Z = np.cos(v)
This is written to a file tmp.dat, and I attempt to plot it in gnuplot with:
set pm3d
set palette
set hidden
splot "tmp.dat" using 1:2:3 with pm3d
However, this gives me:
It's in the general vicinity of what I want, but I'd like a smooth sphere as opposed to this. (My real data is in the same vein; with an enclosed surface I want to have transparency on.) I've tried adding set dgrid3d 50,50 to try and interpolate, however, I don't actually understand what I'm getting from this:
Any help or advice would be enormously appreciated. Changing the data to parametric (with u and v sweep data) is an option, however, I'm not certain how to do that - when I tried, the result was the same.
Not a complete answer, but part of your problem is that "set hidden3d" is not usable here. Gnuplot has two separate subsystems for representing surfaces. One of them, controlled by "set hidden3d", tracks bounding line segments and can remove occluded portions. The other is pm3d, which uses solid-fill quadrangles rather than bounding line segments. pm3d plots do not have the option of removing occluded quadrangles, but you can get a similar effect by depth-sorting them. The relevant command is
set pm3d depthorder
This works reasonably well if the individual quadrangles are approximately square but it gives bad results for long thin quadrangles, since the two ends of the facet can have conflicting depths with regard to neighboring facets.

gnuplot - why plotted lines disappear after certain zoom in level?

I'm completely new to gnuplot.
I'm trying to plot a couple of trivial series of data on one plot.
Actually I mean a small number of simple segments [x1,y1] -> [x2,y2]
But I noticed an annoying behaviour: when I try to zoom my canvas with mouse into specified location, e.g. lines crossing point, my lines eventually disappear. Not all at once - they
disappear one by one at different zoom levels.
I'm not able to examine specific point from close up because of this.
Is it possible prevent my graph elements from disappearing from window?
The behaviour of the plot when one or both end points of a line are outside the displayed range is controllable with set clip.
To have the line portion drawn which is inside the plot but both endpoints being outside, you must use set clip two.
Consider the following example:
plot '-' with linespoints
0.5 0.5
9.5 9.5
e
If you now zoom in, the line disappears. If you use set clip two before, then you can zoom in and the line is drawn:
set clip two
plot '-' with linespoints
0.5 0.5
9.5 9.5
e
(tested to work with 4.6.5)

force graphs legend/key to a specific size

i want to generate some plots from my data that i want to include in some documentation.
I put the box outside the graph area.
the problem is that for different plots the box has different sizes so also the graph area changes its size. this looks very messy in the document becasue the plots are vertical aligned.
I am searching for a way to fix the size of the box to some width that is appropriate for all plots but i could not found a way to do so.
the set key command has a width parameter but it seems not to do that one would expect from such a parameter.
It would be grat if someone could help.
thanks
vlad
I hope I got the correct impression of what you want. Consider the following example
reset
set multiplot layout 2,1
set rmargin screen 0.7
set key reverse Left left top at screen 0.72, graph 1
plot sin(x), cos(x) t 'long title'
plot sin(x), cos(x) t 'very long title'
unset multiplot
Which gives you:
Both the samples and the text do not move. You must only set an appropriate rmargin. left and top is the key box alignment regarding the position specified with at ..., although these settings are default, I explicitely included them for clarity. Left is the alignment of the entry text.

Remove "empty space" in splot with log scaled z axis

I have a gnuplot script which generates a surface plot from data. I've scaled the z axis logarithmically, such as in an example on gnuplot.info1 - and just as in the example, I get a lot of empty room at the "bottom" of the plot.
In that example, the ticks on the z axis end at 1, but the axis doesn't end there - the origin of the plot is further "down" (in the z direction).
How do I set the origin to be where the data actually starts? A dynamic approach (that's not dependent on me knowing the data set in advance) is greatly preferred, if it's possible.
1 Follow the link and search the page for "Surfaces with z log scale" to find the relevant example.
This is not an obvious one, but (as usual) there is a setting for that. Try
set xyplane 1
and
help set xyplane
for more details.

How to make plots larger in GnuPlot

I am generating mapped 3D plots using the following config file (XRANGE and YRANGE are set later)
#!/usr/bin/gnuplot
reset
set term postscript eps enhanced
set size square
set xlabel "X position"
set ylabel "Y position"
#Have a gradient of colors from blue (low) to red (high)
set pm3d map
set palette rgbformulae 22,13,-31
set xrange [0 : XRANGE]
set yrange [0 : YRANGE]
set style line 1 lw 1
unset key
set dgrid3d 45,45
set hidden3d
splot "data.data" u 1:2:3
The resulting image looks something like this
Note: I have converted to jpg so the quality is lower, and I have placed a border around the image.
A great deal of space is wasted above and below. This is not a problem until I embed the image into a LaTex document, at which point it will look like so (again, pdf document converted to jpg image)
The image on the right is also created with GnuPlot, but it is slightly larger (as is evident by looking at the border I have drawn around the top two images). The reason for this is because GnuPlot pads the 3D plot with top and bottom white space. How can I remove this without having to manually edit all 50+ plots I have?
There are two solutions to this, one is unreliable, the other is a hack.
Using GnuPlot, the margin settings can be used to specify distances from the appropriate margins. For example, setting lmargin 0 and bmargin 0 essentially pushes the axes off the page. Similar values can be assigned to the tmargin and rmargin to stretch the graph. Although this worked for 2D graphs, it did not work for 3D graphs (I suspect this has to do with the fact that I set the graph to be a square).
When graphs are set to be of square size, Gnuplot still calculates for the entire screen. The eps file can be manipulated directly to change this by looking for a line like so %%BoundingBox: 50 50 410 302 and changing 410 to something smaller. Alternatively, and this is what I did, you can run eps2eps in.eps out.eps and it will crop it for you. Just make sure in.eps is not the same file as out.eps or it won't work.
I also crop the Bounding Box afterwards, since I hate playing around with margins in gnuplot. I realized that somehow, eps2eps indeed does adjust the bounding box, but it also transforms text (labels etc) into pixel-graphic?!
I usually use "epstool" which conserves text as text when croping the bb, the command I use is:
epstool --copy --bbox in.eps out.eps
Use the <scale> argument in set view, this will magnify the plot without changing text size or title position.
In your case, because you use the map view, you need:
set view 180,0,1.5
where 180,0 is equivalent to map view and 1.5 is the scaling factor.

Resources