Rotating 3D plots with the mouse in multiplot mode - gnuplot

When I do the following in gnuplot ...
set terminal x11
splot sin(x)
I can rotate the 3d plot with the mouse
On the other hand, if I do the following
set terminal x11
set multiplot layout 1,2
splot sin(x)
splot cos(x)
I can't rotate sin(x) or cos(x) even though I would love to. Does anybody know if it is possible to create a multiplot with plots that you can rotate?

Unfortunately you can't. Ethan A. Merritt, one of the gnuplot developers, here explained why:
Fundamental limitation. The "multiplot" command is best understood as
meaning "don't start a new page for the next plot". So your commands
have created two separate plots, that just happen to be on the same
page. Gnuplot only tracks the data for one plot at a time, so you can
only redraw the most recent plot. All earlier plots are long gone.

Related

Trying to plot contours on Mac using the same script I use on windows on gnuplot

I have an issue with gnuplot on Mac. On windows everything seems fine I can easily draw contours on a "heat map". But on my Mac using the same script I can plot the map but not the contours on top of it.
https://imgur.com/a/x00bFnJ here is the two images. One with the contours is on Windows, other one is on Mac.
https://justpaste.it/6ws4h and here is the script.
I tried grid3d but they seem like not nearly accurate as the ones I have plotted on windows.
I cannot explain the difference between your two machines, but I think I can see where the problem arises. The following lines from your script are inconsistent with producing a plot with both a surface and contours shown:
set style data pm3d
set style function pm3d
set pm3d explicit at b
splot DATA with pm3d # command simplified
The issue is that both the default style and the explicit plot command specify pm3d, which is a filled-area surface plot. But contours need to be drawn with lines or with labels. You need some combination of defaults and explicit styles that allows you to mix both a surface and lines. I think either of these would do the trick:
set pm3d explicit
set style data lines
splot DATA with pm3d
or
set pm3d implicit
splot DATA with lines
Well! I will answer my own question.
set pm3d map
set contour surface
set cntrparam ...
sp "DATA" u 1:2:3 with pm3d lw 2,"" u 1:2:3 with lines nosurf
Solved my problem.!

Gnuplot: How to continue a pm3d plot to the outside of the set range?

I have a problem with plotting my data points with pm3d in gnuplot. In my data file, the points (2-dim domain) are not rectangular aligned, but parabolic as shown in this figure, where the data points are not aligned exactly above each other. My goal is to create a heatmap with pm3d for a specific xrange where the heatmap is continued to the borders of the selected xrange.
What I did:
Plotted the data set with pm3d using the following minimal code example:
set terminal qt
set xrange [-0.25:1.00]
set view map
splot "data.txt" u 1:2:3 with pm3d
What I got:
A heatmap of my data file, but with ugly corners at the border points at where I cut my x-domain, because the border points are not aligned "above" each other.
What I expected:
A heatmap where the "heat" values are continued to the real border of the domain as it is the case for a simple "with lines" plot, shown in this figure.
My attempts so far to achieve what I expected:
I tried several pm3d options, including the option clip1in, which only requires 1 clip of a "heat rectangle" to be inside the domain, but the result was that the corners are no laying outside of the domain, which doesn't solve the problem unfortunately.
Additional information:
OS: Ubuntu 20.04
$ gnuplot -V
gnuplot 5.2 patchlevel 8
If anybody knows how I achieve what I'm trying to do, it would be nice to share that knowledge!
Cheers!
Gnuplot 5.4 does offer this sort of smooth clipping on the z coordinate, but unfortunately that doesn't help because you want clipping on x in this case.
Here is an example of performing x clipping by manual intervention.
The complicated expression for the x coordinate is just to generate points
with a non-orthogonal grid.
xclip(x) = x > 6. ? 6. : x # clip x to maximum value of 6.
f(x,y) = sin(sqrt(x*x + y*y)) # some function to plot
set sample 21; set isosample 21
set view map
set xrange [-6 : 6]
unset key
set multiplot layout 1,2
set title "No clipping"
splot '++' using ($1+$2*$2/10.) :($2):(f($1,$2)) with pm3d
set title "Manual clipping at x=6"
splot '++' using (xclip($1+$2*$2/10.)):($2):(f($1,$2)) with pm3d
unset multiplot

First plot disappear when moving mouse wheel

I plot my data with multi-plot(two plots arraged by two rows one column ) by gnuplot5.2 in a script. And I get my plot perfectly--the completed plot is output to screen because I set term win.
But when I move mouse wheel in the window screen, the first plot(the upper one) disappeared and never come back again. Only the second plot remains on screen.
Does anyone meet the same problem? And anyone can help me finding back the disappeared plot on screen?
It seems that moving the mouse wheel triggers a replot which only repeats the last plot command. Therefore I'm afraid that the disappeared plot can not be restored.
But it would be a nice feature.
Update:
If your subplots have the same ranges, you can try this (ugly) workaround. Split your script into two files like that:
# a.plt
reset
set xrange [0:pi]
set yrange [-1:1]
load "b.plt"
and
# b.plt
set multiplot layout 2,1
plot sin(x)
plot cos(x)
unset multiplot
Then, in the first run, start gnuplot and run a.plt with
load "a.plt"
And then, after each mouse wheel action, reload and run b.plt with
load "b.plt"
The two plots must have the same ranges because gnuplot remembers only the last settings, changes them according to your mouse wheel action, and applies them to both plots. In my opinion this is a limitation which renders the workaround nearly unusable.

How to put two plots with inset side by side in gnuplot?

I am trying to create two plots in Gnuplot side by side using multiplot. The problem is that how can I add inset to each one.
I wanted to point your attention to the gnuplot demo page (gnuplot demo page), however, I couldn't find an example of such insets in multiplots right away.
Simply use set multiplot layout 1,2 and continue plotting but with different sizes and offsets. See example below:
Code:
### multiplot with insets
reset session
set multiplot layout 1,2
plot x**2
plot x**3
set size 0.3,0.3
set origin 0.1,0.6
set ytics 0.5
plot sin(x)
set size 0.3,0.3
set origin 0.6,0.6
plot cos(x)
unset multiplot
### end of code
Result:

Is there a bug in Gnuplot 5.2 (patch 5) with `multiplot` command?

I'm running Gnuplot version 5.2, patch level 5, and I am getting unexpected behavior from the multiplot command. In efforts to produce two plots, one smaller and superimposed on the larger one, I am using the multiplot environment in the following way:
reset
set multiplot
set origin 0,0
set size 1,1
plot "first_file.dat"
set origin 5,5
set size 0.5,0.5
plot "second_file.dat"
unset multiplot
When I first run set multiplot an empty canvas shows up that I close. Then, when I enter unset multiplot nothing happens. From following instructions online it seems like the unset command is supposed to produce the plot, but it doesn't. Am I doing something wrong, or is there a potential bug with this version?
Why do you close the empty canvas? You won't see anything until you plot your data. The following code gives two superimposed plots. However, the set origin coordinates are relative to the screen (ranging from 0.0,0.0 to 1.0,1.0). If you want to place the second graph relative to some coordinates of the first graph, this probably would require some calculations.
reset session
set colorsequence classic
set multiplot # will show an emtpy canvas
plot sin(x) lt 1 # will show the first plot
set origin 0.1, 0.45 # origin coordinates are relative to the screen
# not to the coordinates of the first plot
set size 0.5,0.5
plot cos(x) lt 2 # will show the second plot on top of the first plot
unset multiplot
Result (wxt terminal):

Resources