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

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)

Related

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.

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: Too many tooltips appearing at once on HTML canvas, causes browser freeze

I'm using gnuplot to create a scatter plot with potentially quite a few data points (greater than 1,000,000). I use the following command to plot the data and allow tooltips on mouse hover (the terminal is html canvas as these plots are meant to be displayed in a website):
plot "$resultsFile" using 2:(stringcolumn(8) eq "chr$chrom"?\$5:1/0):1 with labels hypertext point pt 7 ps var lc rgb "black"
The issue I'm having is: when I move my mouse over a dense cluster of datapoints, so many tooltips are displayed as the mouse moves that the browser freezes for a few seconds or even longer in an attempt to display them all. Does anyone know a way to stop this from happening? Perhaps by adding a delay before the tooltip is displayed on mouse over.

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.

Gnuplot: line opacity / transparency?

I am using Gnuplot to successfully plot some time series data. However, the series are fairly dense (10,000's of samples in about 5 inches of space), and when I plot multiple series, it is hard to see underneath the series that was plotted on top. Is there any way to make the lines have a bit of opacity or transparency (i.e. make the line transparent so underneath lines are visible)?
Excel has this capability, but I would much prefer to use Gnuplot.
Below is a sample of what I'm talking about. You can't see the red lines under the green lines. I would actually like to add a third time series. I am plotting with the command:
plot [][-3:3] 'samples_all.csv' using 1:7 title 'horizontal' w l ls 1, '' using 1:8 title 'vertical' w l ls 2"
Good news! This has been implemented in gnuplot. Example syntax is
plot x lw 10, -x lw 10 lc rgb "#77000000"
This will plot x as a red line and -x as a transparent black line (it looks gray). The first pair of two characters in the rgb specification define the alpha (transparency) channel ("#AARRGGBB"). The normal syntax ("#RRGGBB") still works.
old (gnuplot < 5.0 or so) answer for reference:
If you want to make lines plotted for time series data, the answer is no (see discussion here). You can't set a line style to be transparent. Transparency only works for filling under curves, and it has to be printed to the right terminal type.
I ran into this problem myself recently, I hope this feature will be added in a future version of gnuplot.
This may be what you're looking for.

Resources