I have the following gnuplot script:
#!/bin/bash
gnuplot << EOF
set term postscript portrait color enhanced
set output 'temp.ps'
set border lw 0.2
unset key
set size 1,1
set origin 0,0
set size ratio 1
set size 0.47,0.47
set mxtics 2; set mytics 4
f(x,z)=z+5-5*log10(x)
set style fill transparent solid 0.1
set yrange [12:-2]; set xrange[0:10000]
plot f(x,17.55) w filledcurve lc rgb "black", \
f(x,17.5) w lines lt 2 lc rgb "green"
EOF
Which gives me an output like this:
I need two fix two things in this image:
1- the filled zone has a black line which delimitates it and this should go away
2- the filling is covering the x and y tics and this should not happen
Thanks!
To address 1):
set style fill transparent solid 0.1 noborder
To address 2):
set grid noxtics nomxtics noytics nomytics front
As a side note, transparent in your set style fill command does nothing in the postscript terminal as it doesn't support solid transparency.
Related
I am trying to plot a heatmap using gnuplot (5.2.8) with the SVG terminal.
Gnuplot interpolates the colors between the center points of the cells.
When I use the pdf terminal the result is as expected and the cells are clear and uniform faces.
How do I turn the interpolation for the SVG terminal off?
#set terminal svg size 600,600
set terminal pdf size 600,600
set style line 12 lc rgb '#ffffff' lt 1 lw 5
set border front 15 ls 12
set grid front ls 12
set datafile separator ','
percent_sample(sample) = sprintf("sample_%d/configuration.csv", sample)
set palette defined (0 '#c00000', 1 '#0000cc') model RGB
unset colorbox
#set cbrange[0:1]
set xrange [-0.5:9.5]
set yrange [-0.5:9.5]
unset key
set tics scale 0
unset xlabel
set xtics 0.5,1
unset ylabel
set ytics 0.5,1
set tmargin 0
set bmargin 0
set lmargin 0
set rmargin 0
#set view map
set output sprintf("sample_conf_%d.pdf", i)
plot percent_sample(i) matrix with image
It is not gnuplot that does the interpolation - it is the SVG viewing program. Leaving aside the question of how you might persuade the viewer not to do this, you can prevent it from happening by using the keyword pixels in the gnuplot command:
plot percent_sample(i) matrix with image pixels
This tells the program to describe each pixel in the output image as a separate rectangle rather than merging them into a stream of contiguous pixels. See also:
heatmaps demo
I want to draw something transparent.
my script is :
set output 'rcut.png'
set term png
set style fill transparent solid 0.2 noborder
set style circle radius 1
set multiplot layout 1,3 title "Error of the model"
set xlabel 'batch id'
set logscale xy
set format x "10^{\%T}"
set format y "10^{\%T}"
set key autotitle columnheader
#
set ylabel "Energy[eV]"
p 'rcut=3' u 1:4 w circles lc rgb "navy", 'rcut=6' u 1:4 w circles lc rgb "dark-pink"
#
set ylabel "Force[eV/{\305}]"
p 'rcut=3' u 1:6 w circles lc rgb "navy", 'rcut=6' u 1:6 w circles lc rgb "dark-pink"
#
set ylabel
p 'rcut=3' u 1:8 w circles lc rgb "navy", 'rcut=6' u 1:8 w circles lc rgb "dark-pink"
#
unset multiplot
and it returns an empty plot file:
enter image description here
but when i set the term emf, there will be data in the image:
enter image description here
but it is not what i want, the points are not transparent.
I really want to figure out why,thank you
Long answer:
gnuplot can support two different png terminals, one based on the gd graphics library and selected by set term png and a second one based on the cairo graphics library and selected by set term pngcairo. The gd version only supports transparency if you specify set term png truecolor, which creates an output png file with 24bits of RGB color per pixel and another 8 bits of transparency. Otherwise it generates png files that are smaller (8 bits per pixel) because they are limited to 256 colors and no transparency. The cairo version always produces files with 24bit RGB + 8bit transparency per pixel.
Short answer:
Use either set term pngcairo or set term png truecolor.
I have code:
set term eps size 1200,150
set output "output.eps"
set tics out
set xlabel "{/:Italic A} (B)"
set ylabel " "
set ytics nomirror
set xtics nomirror
unset ytics
unset key
#set key tc variable
set label "{/:Bold=12 S}" tc rgb "black" at 54250,5.05
set label "{/:Bold=12 F}" tc rgb "black" at 56170,5.05
set label "{/:Bold=12 R}" tc rgb "black" at 56730,5.05
set arrow from 56000,graph(0,0) to 56000,graph(1,1) nohead dt "-" lw 1 lc rgb "grey30"
set arrow from 56500,graph(0,0) to 56500,graph(1,1) nohead dt "-" lw 1 lc rgb "grey30"
plot 'data.txt' title "{/:Bold T data}" with points pt 7 ps 1 linecolor rgb "black",
and the output.eps has 0kb. What is wrong please? output.png is ok with this code.
Edit
.png - desired
.eps
For some terminals the output file is written when the output is "closed". This can be done by:
calling the command set output after the plot command, you have to call another set output <filename> when you want another plot
closing gnuplot, this works automatically if you write your commands into a scriptfile (for example script.plt) and load your gnuplot script from the shell commandline with gnuplot script.plt
I want to plot a filled circle in Gnuplot, but with transparency changing with the distance to the center of the circle, i.e. a transparency gradient (solid near to the center, and transparent near to the radius of circle).
Is there any way of doing this in Gnuplot?
Thank you in advance!
One option would be to define a custom function describing the gradient (e.g., a Gaussian) and then use pm3d map to visualize it:
set terminal pngcairo size 400,400
set output 'fig.png'
unset border
unset colorbox
unset xtics
unset ytics
set pm3d map
#force the plot to occupy the entire canvas
set lmargin at screen 0
set rmargin at screen 1
set tmargin at screen 1
set bmargin at screen 0
set isosamples 100,100
#specify custom palette
set palette model RGB
set palette defined ( 0 "white", 1 "royalblue" )
set xr [-10:10]
set yr [-10:10]
#a Gaussian might be a reasonable choice
splot exp(-0.2*(x*x+y*y))
This then produces:
Another choice of the defining function might be:
set xr [-pi:pi]
set yr [-pi:pi]
fn(r) = (r>(pi/2))?0:(cos(r))
splot fn(sqrt(x*x+y*y))
This yields:
Try this:
set xrange [0:10]
set yrange [0:10]
do for [i=1:100] {
set style fill transparent solid i/100. noborder
set object circle at 5,5 radius 1.-i/100. fc rgb 'blue'
}
plot -1
Not all terminals support transparency; see help transparent. I made this with the terminal x11.
I would like to plot the inverse of y=xe^x, with dashed lines leading to the point (-exp(-1), -1)
set parametric
set style arrow 1 head filled size char 1.5,20,50
set arrow 1 from -4.1,0 to 4.1,0 heads
set arrow 2 from 0,-4.1 to 0,4.1 heads
set trange[-4:4]
set xrange[-4:4]
set yrange[-4:4]
set xlabel "x"
set ylabel "y"
unset border
set xtics axis format " "
set ytics axis format " "
plot [-4:0.999] log(1-t)/t, t
plot [-4:4] t*exp(t), t lt rgb "black" title '', -exp(-1),t lt rgb "black", t, -1 lt rgb "black"
I would like to restrict the vertical line to running from y=-1 to y=0, and the horizontal line from x=-exp(-1) to x=0. How can this be done?
Also, is there an easier way to set the line colour for all plots, rather than specifying it for each one?
I see, if I'm understanding it correctly you basically need to annotate your graph with the dashed lines, so why don't you use arrows for the same too.
For example:
# I'm using pngcairo dashed terminal
set terminal pngcairo dashed
set output 'graph.png'
set parametric
set style arrow 1 head filled size char 1.5,20,50
set arrow 1 from -4.1,0 to 4.1,0 heads
set arrow 2 from 0,-4.1 to 0,4.1 heads
#set trange[-4:4]
set xrange[-4:4]
set yrange[-4:4]
set xlabel "x"
set ylabel "y"
unset border
set xtics axis format " "
set ytics axis format " "
#plot [-4:0.999] log(1-t)/t, t
set arrow from -exp(-1),-1 to -exp(-1),0 nohead lt 3
set arrow from -exp(-1),-1 to 0,-1 nohead lt 3
plot [-4:4] t*exp(t),t lt rgb "black" title ''
As far as your questions about line colours is concerned, it is also dependent on the type of terminal that you are using. For instance, with the pngcairo terminal, Gnuplot will itself assign different linestyles to plots. If you want specific colours, then offcourse you have to state them. Take a look at this link. You'll find lots of info with a simple search on Gnuplot's linestyles/linecolour/linetypes etc.