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

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.

Related

Reverse abscissa/ordinate axis in wxdraw2d or wxplot2d wxmaxima

By default, the draw/plot function plots y-axis values in ascending order (from bottom to top). In other words, -ve values are at the bottom of the graph and +ve values above the origin (towards the top of the plot). Can we reverse (see the figure attached) this behavior for the individual axis or both?
It is possible in gnuplot, by passing set xrange reverse and set yrange reverse, but wxmaxima does not provide a full interface for gnuplot, however, it seems that direct access may be possible. As from the docs:
2.3.5 Opening gnuplot’s command console in plot windows
On MS Windows, if in Maxima’s variable gnuplot_command “gnuplot” is replaced by “wgnuplot”, gnuplot offers the possibility to open a console window, where gnuplot commands can be entered into. Unfortunately, enabling this feature causes gnuplot to “steal” the keyboard focus for a short time every time a plot is prepared.
Please also note that there is a difference in gnuplot 4 and 5:
The reverse keyword of the set [axis]range command aects only autoscaling. It does not invert or
otherwise alter the meaning of a command such as set xrange [0:1]. If you want to reverse the direction
of the x axis in such a case, say instead set xrange [1:0].

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 plane curve

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.

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.

gnuplot ignores x and y ranges when using dgrid3d

I have a file with scattered data (points located approximatelly on the vertices of a regular grid): first two columns are the x and y coordinates, then a few more columns with other data that I need to plot. I want to obtain color maps that represent this data, and since points are scattered I'm using dgrid3d to generate a regular grid and have a smoother representation. My problem is that when I set dgrid3d, gnuplot ignores the x and y ranges and plot the grid outside the figure frame. Bellow is a minimal script to reproduce my problem:
set view map
set yrange [0.4:0.8]
set xrange [0.2:0.8]
set pm3d
set style data lines
set dgrid3d 100,100,4
splot "./Terr.dat" using 1:2:(log($6)) pal
The result that I obtain is the following image:
Setting the option clip1in or clip4in of pm3d has no effect. If I unset view so that the result is a 3D surface, it also ignores the x and y ranges. I could easily write an script to pre-process the data and remove the points outside the range I want, but gnuplot should be able to manage this. Any idea?
I'm using gnuplot 4.2 patchlevel 6
Thanks!
I'm not sure that I am able to reproduce your problem, but there are a few funny things with your script. I'm not exactly sure what the line set style data lines is supposed to do in this context as you're plotting with pm3d. I created a simple datafile:
0 1 4
1 0 5
0 0 2
1 1 3
And I plotted it using this script:
set view map
set yrange [0.4:0.8]
set xrange [0.2:0.8]
set dgrid3d 100,100,4
splot 'test.dat' u 1:2:3 w pm3d
And it seemed to "work" (I'm using gnuplot 4.6.0).
There are a few things of note however -- Notice that every point in my original domain was out of the given x and y ranges. Gnuplot still used those points when constructing the surface. This is also demonstrates reasonably nicely what the gnuplot weighting function looks like (although we could do even better by using only 1 point in our data file.)
UPDATE
Between my 2 computers, I have access to gnuplot4.2.6, gnuplot4.3.0, gnuplot4.4.2, gnuplot4.6.0, gnuplot4.6.1 and gnuplot4.7.0. gnuplot4.2.6 is the only version which exhibits the behavior you describe. It looks to me like they changed the behavior of pm3d in the 4.3 CVS branch, but didn't push those changes back into gnuplot4.2. The easy fix is to upgrade to gnuplot4.6 -- I've been using it as my default gnuplot for a few months now and it seems to be pretty stable.

Resources