Gnuplot svg: change data point color - svg

I am using Gnuplot 5.2 patchlevel 2, and want to make an SVG scatter plot with three different datasets. I cannot change the color of the data points.
set term svg enh size 1800,1800 font "Times,20" rounded background rgb white'
set output 'plot.svg'
set style line 1 lc rgb 'red' pt 7 ps 1 lt 1 lw 2
plot 'data.file' w lp ls 1 ti "Set 1"
The data points remain black, but the lines are (correctly) red. This is something unexpected, it works in the other terminals.

Related

transparent point plot does not work [duplicate]

How can I plot an image with partially transparent scatter points, just like in the picture below, with Gnuplot? The problem is that I don’t know how to set the points to be transparent.
Try this:
set style fill transparent solid 0.35 noborder
set style circle radius 0.02
plot 'test' u 1:2 with circles lc rgb "blue", \
'' u 1:2 every 100 w circles lc rgb "red" fs solid 1.0 border lt -1
which outputs
As you can see, you can specify for each data set whether to use transparency and which color to use.
If your data consist of two values (x and y position of the circle) you have to specify the circle's radius via set style circle .... If your data has three rows, you can use the third value to specify the circle's radius for each data point.
You can play with the transparency level, which ranges from 0 (full transparency) to 1 (no transparency).
You can use the alpha channel of argb along with lc rgb variable:
set samp 2000
randn(x) = invnorm(rand(x))
pl [-3:3][-3:3] '+' us (randn(0)):(randn(0)):(0xBB00AAFF) lc rgb variable pt 7 ps 2
.
This leaves some egde around each circle, probably an opacity effect from a circle plus a filled circle on top of it. Unfortunately, there is no edgecolor option as in matplotlib to control this. Replacing filled circles pt 7 with open circles but thick linewidth pt 6 lw 6 can mitigate this a bit
pl [-3:3][-3:3] '+' us (randn(0)):(randn(0)):(0xBB00AAFF) lc rgb variable pt 6 lw 6
.
One can also emulate a variable transparency with lc rgb variable
set samp 50
pl '+' us 1:1:(0x00AAFF+(int(0xFF*$1/10.)<<24)) pt 7 lc rgb variable ps 3
where int(0xFF*$1/10.) maps the input from 0..10 into 0..255 and <<24 shifts it into the alpha channel.
Note that in your plot only the dense regions seem to have a transparency effect, but not the scatter points in the background.

Gnuplot locally change label font color

I have a gnuplot label for my plot
plot f(x) title 'Before(w)' with lines ls 1
In my label there is Before(w). I would like the color of a letter w to be red. How can I do it?
I was able to find code that changes the color of the whole label (http://www.gnuplot.info/demo_4.6/textcolor.html) but it is not what I want.
Thanks.
Working example
set terminal postscript eps size 3.5,2.62 enhanced color \
font 'Helvetica,20' linewidth 2
set output 'plot2.eps'
set style line 1 linecolor rgb '#0060ad' linetype 1 linewidth 2 #(gnuplotting)
f(x) = exp(-x*x)
plot f(x) title 'Before(w)' with lines ls 1

How to make scatter plots with semitransparent points in Gnuplot?

How can I plot an image with partially transparent scatter points, just like in the picture below, with Gnuplot? The problem is that I don’t know how to set the points to be transparent.
Try this:
set style fill transparent solid 0.35 noborder
set style circle radius 0.02
plot 'test' u 1:2 with circles lc rgb "blue", \
'' u 1:2 every 100 w circles lc rgb "red" fs solid 1.0 border lt -1
which outputs
As you can see, you can specify for each data set whether to use transparency and which color to use.
If your data consist of two values (x and y position of the circle) you have to specify the circle's radius via set style circle .... If your data has three rows, you can use the third value to specify the circle's radius for each data point.
You can play with the transparency level, which ranges from 0 (full transparency) to 1 (no transparency).
You can use the alpha channel of argb along with lc rgb variable:
set samp 2000
randn(x) = invnorm(rand(x))
pl [-3:3][-3:3] '+' us (randn(0)):(randn(0)):(0xBB00AAFF) lc rgb variable pt 7 ps 2
.
This leaves some egde around each circle, probably an opacity effect from a circle plus a filled circle on top of it. Unfortunately, there is no edgecolor option as in matplotlib to control this. Replacing filled circles pt 7 with open circles but thick linewidth pt 6 lw 6 can mitigate this a bit
pl [-3:3][-3:3] '+' us (randn(0)):(randn(0)):(0xBB00AAFF) lc rgb variable pt 6 lw 6
.
One can also emulate a variable transparency with lc rgb variable
set samp 50
pl '+' us 1:1:(0x00AAFF+(int(0xFF*$1/10.)<<24)) pt 7 lc rgb variable ps 3
where int(0xFF*$1/10.) maps the input from 0..10 into 0..255 and <<24 shifts it into the alpha channel.
Note that in your plot only the dense regions seem to have a transparency effect, but not the scatter points in the background.

GNUplot - plot data file (simple X and Y columns) - setting suitable color and scale on a figure

I have a simple file with two columns:
1 0.005467
2 0.005333
3 0.005467
4 0.005467
5 0.005600
6 0.005600
7 0.005467
8 0.005467
In the first column I have the x-axis values, while on the second column I have y-axis values. I would like to plot a figure of this data. I wrote a gnuplot script for this:
#!/usr/bin/gnuplot
set xlabel "test"
set ylabel "value"
set grid ytics lt 0 lw 1 lc rgb "#bbbbbb"
set grid xtics lt 0 lw 1 lc rgb "#bbbbbb"
set autoscale
set terminal postscript portrait enhanced mono dashed lw 1 'Helvetica' 14
set style line 1 lt 1 lw 3 pt 3 linecolor rgb "red"
set output 'out.eps'
plot 'data.txt' using 2:1 w points title "tests"
And, the output:
But of course, as a newbie in gnuplot, I have some troubles:
How to change the crosses on the fingure into dots?
How to change the color of the dots, to let's say, red? ( my command in my gnuplotscript seems not to work at all ...)
For the first test the adequate, accurate, exact value is 0.005467 but on my figure it doesnt look like so... I would like to place the dot on my figure for the first, second, third, (so on) test on the exact place, where is appropriate value.
How to add a grid to my figure? - SOLVED
How to get rid of the ugly text: 'data.txt' using 1:2 and replace it with a legend? - SOLVED
EDIT (SOLVED ISSUE NO 5)
plot 'data.txt' using 1:2 w points title "tests"
EDIT (SOLVED ISSUE NO 4)
set grid ytics lt 0 lw 1 lc rgb "#bbbbbb"
set grid xtics lt 0 lw 1 lc rgb "#bbbbbb"
You should read a bit in the documentation about all your commands!
Several remarks:
If you want colored points, you shouldn't use the mono (i.e. the monochrome) option, but rather color.
Your definition of the line style is correct, but in order to use it you must use linestyle 1 when plotting. Otherwise the linetype 1 is used. Compare:
set style line 1 lt 1 lw 3 pt 3 linecolor rgb "red"
plot x, 2*x linestyle 1
In order to see all the dots of a terminal, use the test command:
set terminal postscript eps enhanced color dashed lw 1 'Helvetica' 14
set output 'test.eps'
test
set output
You see, that for filled dots you must use pt 7.
I'm sure, that the points are shown at the correct values. Use
set ytics add (0.005467)
to see this.

Gnuplot change color of bars in histogram

is it possible to change the color of bars in a Gnuplot script dynamically?
I have the following script
reset
fontsize = 12
set term postscript enhanced eps fontsize
set output "bargraph_speedup.eps"
set style fill solid 1.00 border 0
set style histogram
set style data histogram
set xtics rotate by -45
set grid ytics linestyle 1
set xlabel "Benchmarks" font "bold"
set ylabel "Relative execution time vs. reference implementation" font "bold"
set datafile separator ","
plot 'bm_speedup.dat' using 2:xtic(1) ti "Speedup" linecolor rgb "#00FF00"
which generates this plot:
Is it possible to make the color of the bars which are below zero red?
Thanks,
Sven
You can mimic this behavior using the boxes style:
My test data:
zip 2
baz 2
bar -1
cat 4
foo -3
And then plotting with gnuplot:
set style line 1 lt 1 lc rgb "green"
set style line 2 lt 1 lc rgb "red"
set style fill solid
plot 'test.dat' u (column(0)):2:(0.5):($2>0?1:2):xtic(1) w boxes lc variable
# #xval:ydata:boxwidth:color_index:xtic_labels
You could split your data file into two parts, positive values and negative, and plot them separately:
plot 'bm_speedup_pos.dat' using 2:xtic(1) ti "Faster" linecolor rgb "#00FF00", \
'bm_speedup_neg.dat' using 2:xtic(1) ti "Slower" linecolor rgb "#FF0000"
Or, if you only need to generate a few graphs, a few times, a common technique is to generate the raw graph in gnuplot, then post-process it in an image editor to adjust the colors. If you go that route, I suggest having gnuplot generate the graph in SVG format, which will give you much better looking graphs than any of the bitmap formats.
Doesn't seem like histogram lets you do it. May be like this:
set boxwidth 0.3
f(v)=v<0?1:2
plot 'bm_speedup.dat' using 0:2:(f($2)):xticlabels(1) with boxes ti "Speedup" lc variable
Actually you can also use linecolor rgb variable and give the color like this:
plot 'bm_speedup.dat' using 2:xtic(1):($2 >= 0 ? 0x00FF00 : 0xFF0000) ti Speedup lc rgb variable

Resources