What is the best way to fill large region in gnuplot with transparent color? - gnuplot

I'm trying to plot my result from verification with gnuplot. Now I am trying to draw unsafe region for this picture. The imagine shows below. Suppose unsafe set is x > 3, then everything above x = 3 should be filled with transparent colour to indicate it is an unsafe region. I am new to gnuplot, and I am thinking to draw a large rectangle with transparent colour, but is there a better way to achieve this in gnuplot? Thank you.

Yes, drawing a rectangle is a good option for your use case:
set object rectangle from graph 0, first 3 to graph 1, graph 1 fillcolor rgb 'red' fillstyle transparent solid 0.5 noborder
plot ...
Using the graph coordinates makes three borders of your rectangle independent of the axes ranges.

Related

How to show a grid with two filled plots

I am plotting to datasets with 'fillsteps' one below another and I want the plot two show only the area that is a difference between the two
plot [0:1][0:1] x with fillsteps above fill solid not,x**2 with fillsteps above fill solid lc rgb 'black' not
But the grid obviously gets blocked in this case:
Is there any way to create something like a cross-section between the two areas, show the grid and get rid of those nasty artifacts that are seen below?
Ok, basically you want to fill the area between two curves (either lines or steps) and have a grid on top. The set grid front you found yourself, but let me make another suggestion.
For the first case (lines), i.e. a fill between lines, you can simply use 3 columns (check help filledcurves) and then the area will be filled between the curves:
plot '+' u 1:(f1(x)):(f2(x)) w filledcurves
For the second case (steps), I don't see (yet) such an option with filledsteps. Actually, from your option above I assume you are using gnuplot5.5.
In general, I wouldn't call it a "clean" solution if you plot something and partly have to cover it with something else with background color. What if you want a transparent background? A transparent color which covers something colored has not yet been invented ;-), there is no such "invisible" color. For another example check this.
Furthermore, with fillsteps I can also observe the artifacts of vertical gap lines which you see in your graph, but I don't have a good solution to avoid them.
Hence, my suggestion is to plot only there where you need something to plot. Actually, you can mimic the fillsteps behaviour. It's not obvious how to do it, but not too difficult. While you plot line by line, you remember the previous x-value and function values of f1(x0) and f2(x0) in x0, y0 and y2, respectively. You plot with the plotting style boxxyerror (check help boxxyerror) using x:y:xlow:xhigh:ylow:yhigh.
Script: (works with at least gnuplot>=5.0.0)
### plotting style filledcurves and mimic fillsteps "between"
reset session
f1(x) = x
f2(x) = x**2
set xrange[0:1]
set yrange[0:1]
set key noautotitle
set grid x,y front lw 1.3
set style fill solid 1.0 border
set samples 50
set multiplot layout 2,1
plot '+' u 1:(f1(x)):(f2(x)) w filledcurves
plot x1=y1=y3=NaN '+' u (x0=x1,x1=$1):(y0=y1,y1=f1($1),y2=y3,y3=f2($1)):(x0):(x1):\
(y0):(y2) w boxxy
unset multiplot
### end of script
Result: (download the PNG image and check that the background is transparent).
set grid front
works in this case

Thickness of pattern fill in Gnuplot

I am using Gnuplot and I wish to fill the area between two curves with transparent hatched pattern.
I define fill style with:
set style fill transparent pattern 1
and I plot it as:
plot "Data..." using 4:1:2 with filledcurves lc rgb 'black'
However, the resulting hatched pattern has extremely thick lines. I want to adjust thickness of pattern lines, density of lines etc.
I cannot believe I could not find anyone asking the same thing?

How to get circles with specific radii in pixels in gnuplot

When plotting data using circles, the radii of the circles depend on the data size (i.e. X/Y ranges) according to the answers for the question in Gnuplot: plot with circles of a defined radius .
Is it possible to define a screen delimited radii for the circles instead? That is, I want all the circles to have a specific radius in pixels no matter they size nor the X/Y ranges.
So you are just looking for a plot symbol in the shape of a circle? Then use the usual points style with pointtype 6 (empty circles) or 7 (solid circles), and specify the pointsize scale factor (1 corresponds to default)
plot [0:2] '+' using 1:1 with points pointtype 6 pointsize 1, \
'+' using 1:(sqrt($1)) with points pointsize 1.5 pointtype 7

Transparent background picture and the color of certain points

Basically I have a picture which is a collection of complicated shapes with its own axis and different colours and a data set of points which I can plot on top of it, that works fine, see minimized code example. I am using fortran to generate a gnuplot command file and run gnuplot.
plot "Random.png" binary filetype=png with rgbimage axis x2y2, "xydata1.dat" using 1:2 with points axis x1y1
My problems are that the picture makes it hard to see the points on top. Due to the shapes being a lot of different colours it is impossible to pick a colour for the points which is clearly visible on all shapes.
So could the picture be put in the background at say 50% transparency, without making it transparent in another program?
And is it possible to get the colour of the background on the locations of the points back so that the shape they are in can be determined automatically?
You can use the rgbalpha plotting style and given an explicit transparency value:
plot "Random.png" binary filetype=png using 1:2:3:(127) with rgbalpha axis x2y2\,
"xydata1.dat" using 1:2 with points axis x1y1
The transparency value must be between 0 (completely transparent) and 255 (fully opaque).

Displace z-axis with gnuplot

Is it possible to displace the z-axis to the middle of the x-axis with gnuplot?
I've found a great gnuplot script here which nearly fits my needs perfectly, except that the z-axis should be going up at the middle of the x-axis.
by default gnuplot draws a border and places the labels on this border.
Draw only a border at the bottom, i.e around (x,y)-Plane :
set border 1+2+3+4
or disable it completely:
set border 0
draw a zaxis through the x,y-origin, and place the ztics on the same:
set zzeroaxis lt -1
set ztics axis
same for x and y, if you like.

Resources