gnuplot arrowstyle variable command not respected - vector

I'm trying to color vectors in gnuplot
I have a data file like
0 0 0 1 1 1 1
0 0 0 -1 -1 -1 2
where the last column is to be used to read an arrow style using the "arrowstyle variable" command as in:
set style arrow 1 linecolor rgb "red"
set style arrow 2 linecolor rgb "blue"
set xrange [-1:1]
set yrange [-1:1]
set zrange [-1:1]
splot 'c:\vector.txt'using 1:2:3:4:5:6 with vectors arrowstyle variable
however, the vectors are all black. That is gnuplot isn't reading the style from the data file. I can get this to work if I put the data in two files not not in one.

Related

gnuplot palette for splot 3D surface of errors: symmetrical colors

I am plotting a 3D surface (I have z values on a matrix 8x10 in a text file); The z values represent the error, so it goes e.g. from -20% to +10%. I would like to plot this with colors, in a symmetric way, meaning e.g. -10% needs to be the same red intensity as +10%. The value around 0% (very small errors) needs to be green (or also blue or whatever). So in this way the more intense the red is, the greater the error is (regardless if positive or negative).
I am plotting using:
# line styles
set style line 1 lc rgb '#B2182B' # red
set style line 2 lc rgb '#D6604D' # red-orange
set style line 3 lc rgb '#F4A582' #
set style line 4 lc rgb '#FDDBC7' # pale orange
set style line 5 lc rgb '#D1E5F0' # pale blue
set style line 6 lc rgb '#92C5DE' #
set style line 7 lc rgb '#4393C3' # medium blue
set style line 8 lc rgb '#2166AC' # dark blue
# palette
set palette defined ( 0 '#B2182B',\
1 '#D6604D',\
2 '#F4A582',\
3 '#FDDBC7',\
4 '#D1E5F0',\
5 '#92C5DE',\
6 '#4393C3',\
7 '#2166AC' )
set dgrid3d 30,30 gauss 1
splot 'file.csv' matrix using 1:2:3 with lines palette title 'Error (%)'
I took the line styles and palette from ColorBrewer RdBu.
I tried also centering around zero using stats and set cbrange but without success.
"without success" is not sufficient description to debug. It should work to give the desired symmetric range as set cbrange [-foo : foo]". The numeric values given in the set palette` command are not important so long as they are symmetric. Here is an example
set palette defined (-1 "dark-red", 0 "grey90", 1 "dark-red")
set cbrange [-15 : 15]
set xyplane at 0
splot besj0(y)*x*x with pm3d

gnuplot: default value for heatmap (if no data is available)

Can you tell me how to specify the default cb (or z) value?
I build a 3d chart {x,y,z} or {x,y,cb}, but for different x there are different ranges of y, and as a result white bars are visible on the chart (for heatmap/colorbox). I would like to see no white stripes, and where there is no data, gnuplot would substitute the default value (for example, 0) and, accordingly, paint the field with the appropriate color for heatmap
You have several options, depending on exactly what plot mode you are using and what type of data you have. In general you can use two properties of the color assignment to get what you want:
1) out-of-bound values are mapped to the color of the extreme min or max of the colorbar. So one option is to assign a palette that has your desired "default" color at the min and max, independent of whatever palette function you use for the rest of the range
2) data values that are "missing" or "not-a-number" generally leave a hole in the grid of a pixel image or heat map that lets the background color show through.
There is a demo imageNaN.dem in the standard demo set that shows use of these features for several 2D and 3D heat map commands. The output from a heatmap generated by splot $matrixdata matrix with image is shown below.You can see extreme values pinned to the min/max of the colorbar range.
Note that if you want some color other than the backgroundn to show through, you could position a colored rectangle behind the heat map surface.
# Define the test data as a named data block
$matrixdata << EOD
0 5 4 3 0
? 2 2 0 1
Junk 1 2 3 5
NaN 0 0 3 0
Inf 3 2 0 3
-Inf 0 1 2 3
EOD
set view map
set datafile missing '?'
unset xtics
set ytics ("0" 0.0, "?" 1.0, "Junk" 2.0, "NaN" 3.0, "Inf" 4.0, "-Inf" 5.0)
set cblabel "Score"
set cbrange [ -2.0 : 7.0 ]
splot $matrixdata matrix using 1:2:(0):3 with image
#Ethan, I really don't have some data, which results in white slits.
I can fill in the missing data 0 at the stage of forming the data file, but then some files become very large and gnuplot spends all the memory.
So I'm looking for a way to solve the problem.
My example:
For #Ethan: my code:
set arrow from 0,86400 rto graph 1, graph 0 nohead ls 5 front
#===> decision of problem
set object rectangle from graph 0, graph 0 to graph 1, graph 1 behind fc rgbcolor 'blue' fs noborder
set pm3d map
# set pm3d interpolate 32,32
set size square
set palette rgbformulae 22,13,-31
splot inputFullPath u 2:1:(percentage($4)) notitle
and my data (for example):
0 1 0.1
0 2 0.2
0 4 0.5
# -------- {0,5..7} - white gap
# -------- {1,1..3} - white gap
1 3 0.6
1 4 0.5
1 7 0.9

gnuplot splot with multiple data sets

I have a script that generates a gnuplot file, I have edited so I have 2 sets of data in the same plot. One is multiplied by -1 to change color. However, only one set appears in the plot, the last one stated. The script is the following.
set arrow from graph 0,first 0.61237, graph 0 to graph1,first0.61237,0 nohead front lt -1
set arrow from graph 0,first 1.67303, graph 0 to graph 1,first 1.67303,0 nohead front lt -1
set arrow from graph 0,first 2.53906, graph 0 to graph 1,first 2.53906,0 nohead front lt -1
set arrow from graph 0,first 3.24616, graph 0 to graph 1,first 3.24616,0 nohead front lt -1
set arrow from graph 0,first 3.74616, graph 0 to graph 1,first 3.74616,0 nohead front lt -1
set arrow from graph 0,first 4.74616, graph 0 to graph 1,first 4.74616,0 nohead front lt -1
set pm3d at b
unset surf
set view 180,90
set palette defined (-1 "red",0 "white", 1 "blue");
set grid xtics mxtics ytics
unset border
set xrange [-10:40]
set xtics -10,((40+10)/5),40
set mxtics 3
set yzeroax lt 2
set ytics ("L" 0.0,"K" 0.61237,"G" 1.67303,"L" 2.53906,"W" 3.24616,"X" 3.74616,"G" 4.74616)
set cbrange resto
set cbrange[-1:1]
set colorbox
set terminal png enhanced nocrop size 1920,1080
set out "SPF_NO_SO.png"
splot "specfun.pm3d" u ($1*13.60569806):2:(1*$4/476.70750366666666666666),\
"specfun.pm3d" u ($1*13.60569806):2:(1*$3/573.04673900000000000000)
unset out
Sample image:
The script produces the desired plot only for the negative set. If I flip the order I get the blue one.
Here is a sample data:
data_sample
FYI-these arrays are quite big
as #user8153 pointed out, I also don't see a reason why using splot.
And as #Christoph pointed out it's difficult without knowing how the data looks like,
for example, what's in columns $3 and $4?
By the way, with your plot command ...u ($1*13.60569806):2 aren't you plotting the same function twice on top of each other, i.e. that's why you see either the red or the blue?
Nevertheless, I tried to anticipate what you probably want to do. I scaled the second function and assumed something linear for columns $3 and $4. Please clarify.
With the code:
### start code
reset session
# generate some dummy data
undefine $Data
set print $Data append
do for [n=1:5] {
a = rand(0)*10
b = rand(0)*0.1+0.1
c = rand(0)*20
do for [i=1:100] {
print sprintf("%g\t%g\t%g\t%g",i,(a*sin(b*i-c)),cos(b*i),cos(b*3*i))
}
print "" # insert empty line for data curve separation
}
set print
# print $Data
# end generating dummy data
set palette defined (-1 "red",0 "white", 1 "blue")
set cbrange [-1:1]
plot $Data u 1:2:($3-$4) w l lc palette z
### end of code
You'll get the following:

Draw front arrow over image

I have the following image using the code
set terminal png
set output 'plot.png'
set xlabel "GC (%)"
set ylabel "Proportion of genome"
set sample 1000
set xrange[0:100]
set yrange[0:]
set boxwidth 1
set style fill solid
set key off
set style line 1 lt 1 lc rgb "#0000FF" lw 3
set style line 2 lt 2 lc rgb "#32CD32" lw 3
Cauchy(x,xo,wi) = (1./pi) * wi / ((x - xo)**2 + wi**2)
plot 'compositionGC.txt' w boxes, 0.368187*Cauchy(x, 41.4226,1.72758) + 0.631813*Cauchy(x, 51.8272, 0.464711) ls 2
set yrange[0:GPVAL_Y_MAX]
set arrow from 47.2,0 to 47.2,GPVAL_Y_MAX front ls 1
replot
I have everything I need except that I want a vertical blue arrow separating the two peaks at 47.2 in the x-axis in the front. I cannot get it to work.
Do not change the yrange and replot.
Use this arrow command before the initial plot:
set arrow 1 from 47.2, graph 0 to 47.2, graph 1 front lc "blue"

gnuplot error:"Tic label does not evaluate as string!" in bar chart

I'm working on Gnuplot 4.6 patch 4.
I want to create the bar chart with palette. I've followed this but I got error:
Tic label does not evaluate as string!
Yes, the different with the reference that I mentioned above are the xtics. My graph uses string in xtics.
Here is my sample data:
off 100.0
gpl 60.0
docs 99
vim 9.4
box 95
goo 60
ama 99.9
eba 99.98
and my plot file is:
set term pos eps font 20
set style data histogram
set style histogram rowstacked
set boxwidth 0.75
set format y "%.0f%%"
set style fill solid border -1
set xtics font "Times-Roman, 15" rotate by 45 right
#set xtics center offset 0,-1
set ytics font "Times-Roman, 15"
set palette defined ( 0 "#FFFFFF",\
1 "#FFCCCC",\
2 "#FF9999 ",\
3 "#FF6666",\
4 "#FF3333",\
5 "#FF0000",\
6 "#CC0000",\
7 "#C00000",\
8 "#B00000",\
9 "#990000",\
10 "#A00000")
set ylabel "Percentages"
#set xlabel "Services"
set yrange [70:100]
set output 'a2.eps'
plot 'a2.dat' \
using ($2):xtic(1):($2<=10 ? 0 : $2<=20 ? 1 : 2) t '' with boxes palette
Thanks for help!
The xtic label part should always be the last in a using statement. Also, when using the boxes plotting style you must specify x, y and color values:
plot 'a2.dat' \
using 0:2:($2<=10 ? 0 : $2<=20 ? 1 : 2):xtic(1) t '' with boxes palette
Note, that with boxes overwrites the histogram style you set earlier. Also, the values given in the palette aren't absolute values, but those color values are scaled to accomodate your effictive color range of [0:2].

Resources