Symbol color in postscript terminal - gnuplot

I've a top view of a pm3d plot in black and white. I am rendering the plot via postscript terminal enhanced eps.
I've to place zeta symbol over the data in white color. I've used
set label "{/Symbol=11 \245} = 1.0" at first 0.25, first 0.75 tc rgbcolor "#FFFFFF"
command. But the symbol is being rendered in black color. My terminal command is
set term postscript eps enhanced color font "Helvectica, 9" size 6.5cm, 6cm.
I've removed the tag color, and yet the color is still black.
What could be the command for a white symbol? I'm using gnuplot version 5.2.
My *.eps output:
/Helvetica findfont 90 scalefont setfont
1.000 UL
LTb
LCb setrgbcolor
1105 1598 M
63 0 V
1.000 UP
stroke
LCb setrgbcolor
644 1547 M
[ [(Symbol) 110.0 0.0 true true 0 (z)]
[(Helvetica) 90.0 0.0 true true 0 ( = 1.0)]
] -36.7 MLshow
I've attached below the image of the output, where I've shown what label appears as (I've moved it to x position 0.5).

Your command works correctly when run here, or at any rate it prints a label in white. Note, however
The symbol \245 renders as ∞ rather than ζ. I think you want \172.
The font name Helvetica is misspelled.
To make sure the label is not hidden by the pm3d surface you should add the "front" attribute.
I split the command into three lines for clarity
set label 1 "{/Symbol=11 \172} = 1.0" at first 0.25, first 0.75
set label 1 tc rgbcolor "#FFFFFF"
set label 1 front
The corresponding code in the *.eps output looks like this:
1.00 1.00 1.00 C
1144 2527 M
[ /Symbol reencodeISO15 def
[(Symbol) 110.0 0.0 true true 0 (z)]
[(Helvetica) 90.0 0.0 true true 0 ( = 1.0)]
] -36.7 MLshow
The first line sets the color to white.
The second line moves to the position on the page.
The following four lines print the label.
Does your output produce a different sequence of PostScript commands? Showing the relevant fragment of the output might help debug the problem.
EDIT
The equivalent section of *.eps output if the terminal is set term postscript eps mono rather than set term postscript eps color:
LCb setrgbcolor
1144 2527 M
[ /Symbol reencodeISO def
[(Symbol) 110.0 0.0 true true 0 (z)]
[(Helvetica) 90.0 0.0 true true 0 ( = 1.0)]
] -36.7 MLshow

Related

Gnuplot - How to splot surface and points with dgrid3d

I have a .dat file that I need to plot as a surface :
functionVisu.dat
X Y Z
0 -3.9 1.68777
0 -4 1.7568
0 -4.1 1.81828
0 -4.2 1.87158
0 -4.3 1.91617
0 -4.4 1.9516
0 -4.5 1.97753
0 -4.6 1.99369
0 -4.7 1.99992
0 -4.8 1.99616
0 -4.9 1.98245
-0.1 -3.9 1.68277
-0.1 -4 1.75181
-0.1 -4.1 1.81328
-0.1 -4.2 1.86658
-0.1 -4.3 1.91117
-0.1 -4.4 1.94661
-0.1 -4.5 1.97253
-0.1 -4.6 1.9887
-0.1 -4.7 1.99493
-0.1 -4.8 1.99117
-0.1 -4.9 1.97746
-0.2 -3.9 1.66783
-0.2 -4 1.73687
etc
But also need to plot points on this surface, the file containing the points (pointVisu.dat) is also XYZ values.
The problem is, with my actual script:
set hidden3d
set dgrid3d 50,50 qnorm 2
splot [-10:10][-10:10] "functionVisu.dat" with lines, "pointVisu.dat" with dots lw 10 lc rgb "red"
pause -1
the result I am getting is not looking as expected :
result
My points are spreaded due to the dgrid3d, but I can't manage to make them appear as wanted. Also, with the use of qnorm 2, the points are under the surface function even though they are strict images of it.
Points under the surface
I can have the result I want but without using dgrid3d, which gives me a good but not aesthetic result:
Wanted but bad result
How could I combinate the render of dgrid3d but with single points displaying properly ?
Thanks
Gnuplot version 5.4.3 (Dec 2021) introduced a keyword "nogrid" that can be added to the splot command so that points are plotted individually rather being used for a grid. So if your copy of gnuplot is new enough, the answer to one of your questions is shown below (using some other data)
set hidden3d
set dgrid3d 25,25
splot "foo.dat" with lines title "gridded", \
"foo.dat" with points nogrid pt 7 title "nogrid"
Fallback for older gnuplot versions
For older gnuplot versions that do not recognize the nogrid keyword there is a work-around. Not all plot styles can be gridded, and this includes the with labels plot style. But labels can have an associated point, so you can plot a set of non-gridded points by describing them as labels with blank text:
splot "foo.dat" using 1:2:3 with lines title "gridded", \
"foo.dat" using 1:2:3:("") with labels point pt 7 title "nogrid"

GNUPLOT splot color palete matching jetmap

I'm trying to reproduce the following image of rosenbrock function in gnuplot. Source Wikipedia.
My understanding is that the image was created using JET colormap in Matlab/Matplotlib.
Here is my attempt in gnuplot. Macro MATLAB was sourced from here and Macro JET was sourced from here.
I think bringing the orange/yellow all the way down to 500 would be helpful. I'm not sure how to do this in gnuplot.
Also what would be the size to reproduce MATLAB like view?
reset session
set terminal wxt size 800,600 enhanced font 'Verdana,10' persist
set view 50,330
set isosample 30
set xlabel "x"
set ylabel "y"
set zlabel "f(x,y)" rotate
set pm3d
set macros
JET="define (0 0 0 0.5, 1./8 0 0 1, 3./8 0 1 1, 5./8 1 1 0, 7./8 1 0 0, 1 0.5 0 0)"
MATLAB = "defined (0 0.0 0.0 0.5, \
1 0.0 0.0 1.0, \
2 0.0 0.5 1.0, \
3 0.0 1.0 1.0, \
4 0.5 1.0 0.5, \
5 1.0 1.0 0.0, \
6 1.0 0.5 0.0, \
7 1.0 0.0 0.0, \
8 0.5 0.0 0.0 )"
set palette #JET
splot [x=-2:2] [y=-1:3] (1-x)**2+100*(y-x**2)**2 with pm3d notitle
set output
color mapping
I think you will be most of the way there if you change the color mapping to log scale,
and the rest of the way there if you adjust the lower bound on the palette range:
# ... as above ...
set log cb
set cbrange [0.1 : *]
unset mcbtics
replot
bounding box
gnuplot version 5.4:
set wall x1 fillcolor "gray90"
set wall y1 fillcolor "gray90"
set wall z0 fillcolot "gray50"
set xyplane at 0
set border 127
set grid vertical
replot

Gnuplot - cannot change colors of bars

Given dataset:
0 t1 0.52
1 t2 0.66
2 t3 0.58
3 t4 0.57
4 t5 0.68
5 t6 0.61
6 t7 0.55
7 t8 0.52
8 t9 0.58
9 t10 0.50
10 t11 0.59
I cannot manage to get the colors of the bars to change. What I'm trying below is to color green the highest score which happens on line 4. Please have a look over the below:
set terminal postscript eps enhanced 20
set output "edscore2_joint.eps"
set style line 1 lc rgb "#5F9EA0"
set style line 2 lc rgb "#DC143C"
set style line 3 lc rgb "green"
set yrange [0:1]
set ylabel "ed_{score}"
set xlabel "Technique"
set style fill solid
set boxwidth 0.5
set xtics rotate by -45
plot "edscore2_joint.dat" using 1:3:xtic(2) with boxes ls 1 fillstyle pattern 1 notitle ,\
"edscore2_joint.dat" every ::4::4 using 1:3:xtic(2) with boxes ls 3 fillstyle pattern 2 notitle ,\
"edscore2_joint.dat" using 1:($3+0.05):3 with labels notitle
The terminal postscript is monochrome by default. Use either the option color, or, if you have a recent enough gnuplot version, use the terminal epscairo.

setting space between legend/pattern with the text in stacked bar-chart

I have gnuplot data file:
CS 31.73 18.32 20.78 22.88 1.97 1.29 0.90 2.01
FL 43.27 29.45 15.64 6.55 1.64 1.27 2.18 0.00
HB 32.44 20.43 14.89 14.53 5.42 10.92 0.80 0.31
HD 28.53 7.27 29.53 20.33 9.18 0.93 2.04 1.44
MR 22.56 36.19 10.66 15.51 9.45 4.32 0.80 0.31
ZK 27.15 10.81 27.40 16.10 8.05 7.24 1.06 1.71
All 30.00 21.35 18.05 16.82 6.14 5.39 1.11 0.85
And my gnuplot Script:
set term pos eps font 20
set style data histogram
set style histogram rowstacked
set key invert reverse above
set boxwidth 0.8
set format y "%.0f%%"
set border 3
set yrange [0:100]
set size 0.9 , 1.8
set label 1 "1092" at -0.3,103 font "Times-Roman, 17"
set label 2 "500" at 0.7,103 font "Times-Roman, 17"
set label 3 "1000" at 1.8,103 font "Times-Roman, 17"
set label 4 "500" at 2.8,103 font "Times-Roman, 17"
set label 5 "1000" at 3.8,103 font "Times-Roman, 17"
set label 6 "500" at 4.8,103 font "Times-Roman, 17"
set label 7 "500" at 5.8,103 font "Times-Roman, 17"
set output 'aspect.eps'
plot 'a3b-aspect' \
using($2):xtic(1) t "pattern 1" lc rgb "#006600" lt -1 fs pattern 1, \
'' using($3) t "pattern 2" lc rgb "#006600" lt -1 fs pattern 2, \
'' using($4) t "pattern 3" lc rgb "#330000" lt -1 fs pattern 3, \
'' using($5) t "pattern 4" lc rgb "#000099" lt -1 fs pattern 4, \
'' using($6) t "pattern 5" lc rgb "#000099" lt -1 fs pattern 5, \
'' using($7) t "pattern 6" lc rgb "#000099" lt -1 fs pattern 6, \
'' using($8) t "pattern 7" lc rgb "#000099" lt -1 fs pattern 7, \
'' using($5) t "pattern 3" lc rgb "#660000" lt -1 fs pattern 3, \
'' using($6) t "pattern 3" lc rgb "#990000" lt -1 fs pattern 3
Output:
I have to delete some space between legend(patterns above) and text. Could we custom rectangle size on that? and also invert my legend order... the bottom patterns in bar chart should be the first legend.
Thanks
The default justification of the legend key is Right which isn't appropriate when using reverse like you do: Set the Left option.
Optionally you can also increase or decrease the space reserved for the text with the width option.
To have to lower row appearing first, don't use the invert option.
So with the key settings
set key reverse above Left width 1
you get the result

Gnuplot error bars values below 1 doesn't appear

I have those data:
Length A B C D E F A_err B_err C_err D_err E_err F_err
17 0,51 1,4 0 0 0 0,07 0,11 0,33 0 0 0 0,08
18 1,33 2,49 1,88 0,51 1,21 0,2 0,18 0,43 1,05 0,5 0,5 0,14
19 2,56 3,83 3,75 0,76 4,22 0,81 0,25 0,53 1,47 0,61 0,92 0,28
20 8,28 7,22 3,44 5,46 5,16 9,19 0,44 0,72 1,41 1,59 1,02 0,89
21 29,96 20 15,78 16,65 13,66 62,58 0,74 1,11 2,82 2,6 1,58 1,49
22 34,16 42,3 56,25 31,51 37,14 16 0,76 1,37 3,84 3,25 2,22 1,13
23 14,23 16,59 17,03 29,86 21,28 1,55 0,56 1,03 2,91 3,2 1,88 0,38
24 6,98 4,39 1,72 12,58 9,6 9,54 0,41 0,57 1,01 2,32 1,35 0,9
25 1,23 1,02 0,16 1,65 4,55 0,05 0,18 0,28 0,31 0,89 0,96 0,07
26 0,45 0,44 0 0,89 1,76 0 0,11 0,18 0 0,66 0,6 0
27 0,18 0,1 0 0 1,04 0 0,07 0,09 0 0 0,47 0
With this code, I obtain a nice histogram with error bars:
set terminal pngcairo enhanced font "arial,15" fontscale 2.0 size 1600,900
set output 'length.png'
set style fill solid 0.7 border lt -1
set key inside right top vertical Right noreverse noenhanced autotitles columnhead nobox
set grid ytics
set nokey
set style histogram errorbars linewidth 1 gap 3 title offset character 0, 0, 0
set datafile missing '-'
set style data histograms
set xtics border in scale 1,0.5 nomirror offset character 0, 0, 0 autojustify
set xtics norangelimit font ",12"
set xtics ()
set xlabel "n"
set ylabel "Percentage (%)"
set title "length"
set bars 0.3 front
set datafile separator "\t"
set yrange [ 0 : * ] noreverse nowriteback
plot 'length.dat' using 2:8:xtic(1), '' u 3:9:xtic(1), '' u 4:10:xtic(1), '' u 5:11:xtic(1), '' u 6:12:xtic(1), '' u 7:13:xtic(1)
The obtained image is here: http://i.stack.imgur.com/s88QJ.png
But, some error bars just not appear. I notice that is because the error value is below 1. But why ? I'd like all error bars appearing. Is there a problem in the code that forbid errors below 1 to appear ?
Thanks for your help
To me, it looks like your problem is that you're using , as a decimal point character in your file instead of . that gnuplot understands natively. There are two possible solutions. The first I found from googling, but can't test:
set locale
or
set locale "ja_JP.UTF-8" #gnuplot complains this isn't available for me ...
or perhaps set decimalsign local "..."
The second solution is a little less elegant, but it involves converting all of your , to . in your datafile. That's a trivial thing to do using sed:
sed -e 's/,/\./g' length.dat > length2.dat
Now you can just plot using length2.dat and it should work OK (it did for me). As an aside, I think that's quite a nicely colorful plot. The pngcairo terminal does a good job with it.

Resources