Title for each plot in multiplot - plot

I am doing this plot in gnuplot
enter image description here \
and I don't know why there is no legend with the colors of the curves.
I am using the following these lines in the terminal,
<<<
mySplitX = 0.33
unset key
set samples 200
set multiplot
set border 7
set origin 0,0
set size mySplitX,1
set margins -1, 0, -1, -1
set xlabel " "
set format x "%g"
set mxtics 10
set logscale x
set xrange [1:30]
set ylabel "C_l^{TT}[{/Symbol=10 m}K^2]"
set ytics nomirror
set mytics 5
set yrange [0:15000]
plot "<(sed -n '1,30p' CMB-TT_data_Planck_cleaned.dat)" u 2:3:($3-$4):($3+$5) lc 7 pt 7 ps .5 w errorbars notitle, "explanatory00_cl.dat" u 1:2 notitle w l lc 6, "CDM00_cl.dat" u 1:2 w l lc 4
set arrow 1 from screen mySplitX
set border 13
set origin mySplitX,0
set size 1-mySplitX,1
set margins 0, -1, -1, -1
set xlabel " l"
set xtics add (30)
set mxtics 5
unset logscale x
set xrange [30:2500]
unset ylabel
unset ytics
set y2tics
set my2tics 5
set format y2 ""
plot "<(sed -n '1,30p' CMB-TT_data_Planck_cleaned.dat)" u 2:3:($3-$4):($3+$5) lc 7 pt 7 ps .5 w errorbars notitle, "explanatory00_cl.dat" u 1:2 w l lc 6 t "LCDM", "CDM00_cl.dat" u 1:2 w l lc 4 t "No CDM"
as you can see I am using: title "name" in the same of the comand "plot" but I don't know why this does not work. Could anybody help me, pls?
I am looking for some like this:
enter image description here

Related

How can I draw data 2D at differents points as fenceplot at Gnuplot, with a background transparent?

I have three files where each file is 2D with an x-axis vs y-axis. I plot these files as fenceplot at Gnuplot.
With this code
reset
set term postscript eps color enhanced font "Times,15"
set view 54,111
unset xrange
set xtics +.2
set ytics +.5
set yrange [0:5]
set ticslevel 0
set xlabel "Lc/Lx"
set xlabel font "" textcolor lt -.85 rotate parallel
set ylabel "R"
set ylabel font "" textcolor lt -.85 rotate parallel
set zlabel "{/Symbol D} P / P_{NS}"
set xlabel font "" textcolor lt -.85 rotate parallel
set style fill transparent solid 0.25
set pm3d depthorder
y(x) = sin(x)
set ytics ("0.40" 0, "0.45" 1, "0.50" 2)
splot "PressureDesv.dat0" u 1:(0):2 t "R=0.40", "PressureDesv.dat 1" u 1:(1):2 t "R=0.45", "PressureDesv.dat2" u 1:(2):2 t "r=0.50"
set output "maxwell_speed_distribution.eps"
replot
set output
set term x11
I obtained this plot, but I cannot fill this curves with a background tranparent.
How do I fill these curves with a background tranparency?
Assuming I understood your question correctly, check help zerrorfill and help colorspec and the following example:
Code:
### transparent zerrorfill
reset session
### create some test data
set table $Data
set xrange[0:1]
f(x,a) = a*sin(pi*x)
plot '+' u 1:(f(x,2.0)):(f(x,1.7)):(f(x,1.5)) w table
unset table
set view 55,134
set yrange[0.36:0.54]
set ytics 0.05 offset -1,0
set ztics 0.5
set xyplane relative 0
splot $Data u 1:(0.40):2:(0):2 w zerror fc rgb 0xccff0000 lc "red" ti "R=0.40", \
'' u 1:(0.45):3:(0):3 w zerror fc rgb 0xcc00ff00 lc "green" ti "R=0.45", \
'' u 1:(0.50):4:(0):4 w zerror fc rgb 0xcc0000ff lc "blue" ti "R=0.50"
### end of code
Result:
set style data zerrorfill
set style fill transparent solid 0.5 border
set xyplane at 0
set xrange [0.3 : 0.6]
set xtics (0.40, 0.45, 0.50)
splot FILE1 using (0.40):1:2:(0):2 title "File 1",\
FILE2 using (0.45):1:2:(0):2 title "File 2",\
FILE3 using (0.50):1:2:(0):2 title "File 3"
The column assignments for zerrorfill are x:y:z:zlow:zhigh

gnuplot -- plot range different from axes range

I have this very simple, working gnuplot code:
splot x * x
This plots a surface from -10 < x < 10 and -10 < y < 10.
I want to plot the same surface from -10 < x < 10 and -10 < y < -9 HOWEVER I still want the graph's axes to use -10 < x < 10 and -10 < y < 10. The axes bounds should not change, but the range of values plotted should be smaller.
In other words, the surface should look like a thin band in one small section of the plot. The rest should be empty space. Below is a very poor effort at creating what I want using the graph I have.
I have tried manipulating yrange, but this changes BOTH the surface bounds and the axes bounds. I have also tried disabling autoscale but I'm unsure what to do next.
In current gnuplot (version 5.2.4) you can separate the sampling range from the axis range whether or not you enable parametric mode. See example in the on-line demo set:
sampling.html (see plot #9)
One way to do this is through parametric mode, which gives you a separate set of coordinates (u and v) to set ranges for
f(x,y) = x*x
set xrange [-10:10]
set yrange [-10:10]
set urange [-10:10]
set vrange [-10:-9]
set parametric
splot u, v, f(u,v)
Alternatively you can achieve the same effect by using the ++ special filename instead of parametric mode:
f(x,y) = x*x
set xrange [-10:10]
set yrange [-10:10]
set urange [-10:10]
set vrange [-10:-9]
splot "++" u 1:2:(f($1,$2)) w l
Using a programming language with gnuplot might give better control over plots.
Here is an example using c and a script.
plot.c
#include <stdio.h>
#include <math.h>
int main()
{
int x, y;
double z;
for (y=-10; y <= 10; y++)
{
for (x=-10; x <= 10; x++)
{
z = x * 0.025;
printf("%f %f %f\n", (double)x, (double)y, 100 - cos(z * M_PI*2) * 100);
}
printf("\n");
}
fflush(stdout);
return 0;
}
plot.bat
gcc plot.c -o prog.exe -lm
prog > data.txt
echo splot "data.txt" using 1:2:3 with lines | gnuplot -p
plot.sh
gcc plot.c -o prog -lm
./prog > data.txt
echo 'splot "data.txt" using 1:2:3 with lines' | gnuplot -p
Here is an example using python and a script.
It will output:
plot.py
import math
print("\"Surface One\"")
for y in range(-10, 10+1):
for x in range(-10, 10+1):
z = x * 0.025
print("%f %f %f 1" % (float(x), float(y), 100 - math.cos(z * math.pi*2) * 100))
print("")
print("")
print("\"Surface Two\"")
for y in range(-10, -8+1):
for x in range(-10, 10+1):
z = x * 0.025
print("%f %f %f 2" % (float(x), float(y), 100 - math.cos(z * math.pi*2) * 100))
print("")
print("")
print("\"Surface Three\"")
for y in range(-10, 10+1):
for x in range(-10, 10+1):
z = x * 0.1
print("%f %f %f 7" % (float(x)/2, float(y)/2, math.sin(z * math.pi*2) * 10))
print("")
print("")
plot.bat
cd %~dp0
python plot.py > data.txt
echo ^
set terminal wxt size 570,420; ^
stats "data.txt" u 1:2 nooutput; ^
set border 0x7F linecolor rgb "#555555"; ^
set grid xtics linecolor rgb "#888888" linewidth 0.2 linetype 9; ^
set grid ytics linecolor rgb "#888888" linewidth 0.2 linetype 9; ^
set grid ztics linecolor rgb "#888888" linewidth 0.2 linetype 9; ^
set xrange [-10.0:10.0]; ^
set yrange [-10.0:10.0]; ^
set zrange [-10.0:100.0]; ^
splot for [IDX=0:STATS_blocks-1] "data.txt" i IDX using 1:2:3:4 with lines ^
lc variable title columnheader(1) | gnuplot -p
plot.sh
#!/bin/bash
python plot.py > data.txt
echo \
'set terminal wxt size 570,420; \
stats "data.txt" u 1:2 nooutput; \
set border 0x7F linecolor rgb "#555555"; \
set grid xtics linecolor rgb "#888888" linewidth 0.2 linetype 9; \
set grid ytics linecolor rgb "#888888" linewidth 0.2 linetype 9; \
set grid ztics linecolor rgb "#888888" linewidth 0.2 linetype 9; \
set xrange [-10.0:10.0]; \
set yrange [-10.0:10.0]; \
set zrange [-10.0:100.0]; \
splot for [IDX=0:STATS_blocks-1] "data.txt" i IDX using 1:2:3:4 with lines \
lc variable title columnheader(1)' | gnuplot -p
Example without explicit parametric
This was mentioned at: https://stackoverflow.com/a/51546029/895245 with a link to the docs, here is a minimal example:
set terminal png
set output 'splot-domain.png'
# Number of x and y samples.
set isosamples 10, 5
# Plotted domain.
set urange [-5.0 : 0.0]
set vrange [-5.0 : 5.0]
# Visible domain.
set xrange [-5.0 : 5.0]
set yrange [-5.0 : 5.0]
# Just to make plot look nicer.
set hidden3d
set xyplane at 0
set xlabel 'x'
set ylabel 'y'
splot '++' using 1:2:($2**2) with lines
GitHub upstream.
Output:
Tested on gnuplot 5.2 patchlevel 8.

Multiplotting not showing same y axis range in gnuplot

Plotting two data files using gnuplot (all file contents below) but as shown in the output image below, the y range is varying. I need it to be [0:1] for all plots. What am I missing?
The two data files are data1.dat and data2.dat respectively are :
#x y1 y2 y3 y4
0 0 1.1 0 3.0
1 0 1.5 0 1.9
2 0 2.1 0 2.4
3 0 1.0 0 1.4
4 0 3.2 0 1.6
5 0 2.8 0 1.2
and
#x y1 y2 y3 y4
0 0 1.4 0 3.3
1 0 1.1 0 1.1
2 0 2.3 0 2.1
3 0 1.7 0 1.8
4 0 3.1 0 1.1
5 0 2.3 0 1.3
The gnuplot data.gp file :
set border linewidth 1.5
mpl_top = 0.4 #inch outer top margin, title goes here
mpl_bot = 0.7 #inch outer bottom margin, x label goes here
mpl_left = 0.9 #inch outer left margin, y label goes here
mpl_right = 0.1 #inch outer right margin, y2 label goes here
mpl_height = 1.5 #inch height of individual plots
mpl_width = 1.8 #inch width of individual plots
mpl_dx = 0.3 #inch inter-plot horizontal spacing
mpl_dy = 0.1 #inch inter-plot vertical spacing
mpl_ny = 1 #number of rows
mpl_nx = 4 #number of columns
# calculate full dimensions
xsize = mpl_left+mpl_right+(mpl_width*mpl_nx)+(mpl_nx-1)*mpl_dx
ysize = mpl_top+mpl_bot+(mpl_ny*mpl_height)+(mpl_ny-1)*mpl_dy
# placement functions
# rows are numbered from bottom to top
bot(n) = (mpl_bot+(n-1)*mpl_height+(n-1)*mpl_dy)/ysize
top(n) = 1-((mpl_top+(mpl_ny-n)*(mpl_height+mpl_dy))/ysize)
# columns are numbered from left to right
left(n) = (mpl_left+(n-1)*mpl_width+(n-1)*mpl_dx)/xsize
right(n) = 1-((mpl_right+(mpl_nx-n)*(mpl_width+mpl_dx))/xsize)
set terminal epslatex size 3.5,2.62 color colortext
set output 'data.tex'
set xlabel '$x$'
set ylabel '$y$'
set key off
set multiplot
#-----------------------------------------------
# set horizontal margins for first column
set lmargin at screen left(1)
set rmargin at screen right(1)
# set horizontal margins for first row (bottom)
set tmargin at screen top(1)
set bmargin at screen bot(1)
stats "data1.dat" u 2 name "A"
stats "data2.dat" u 2 name "B"
if (A_max <= 0.0) {A_max = 0.00001; set yr[0:1]}
if (B_max <= 0.0) {B_max = 0.00002; set yr[0:1]}
plot 'data1.dat' u 1:(A_max>B_max ? $2/A_max : $2/A_max) w l dt 1 lt rgb "red", 'data2.dat' u 1:(A_max>B_max ? $2/A_max : $2/A_max) w l dt 1 lt rgb "blue"
#-----------------------------------------------
unset yr
unset ylabel
#-----------------------------------------------
# set horizontal margins for second column
set lmargin at screen left(2)
set rmargin at screen right(2)
# set horizontal margins for first row (bottom)
set tmargin at screen top(1)
set bmargin at screen bot(1)
stats "data1.dat" u 3 name "A"
stats "data2.dat" u 3 name "B"
if (A_max <= 0.0) {A_max = 0.00001; set yr[0:1]}
if (B_max <= 0.0) {B_max = 0.00002; set yr[0:1]}
plot 'data1.dat' u 1:(A_max>B_max ? $3/A_max : $3/A_max) w l dt 1 lt rgb "red", 'data2.dat' u 1:(A_max>B_max ? $3/A_max : $3/A_max) w l dt 1 lt rgb "blue"
#-----------------------------------------------
unset yr
#-----------------------------------------------
# set horizontal margins for third column
set lmargin at screen left(3)
set rmargin at screen right(3)
# set horizontal margins for first row (bottom)
set tmargin at screen top(1)
set bmargin at screen bot(1)
stats "data1.dat" u 4 name "A"
stats "data2.dat" u 4 name "B"
if (A_max <= 0.0) {A_max = 0.00001; set yr[0:1]}
if (B_max <= 0.0) {B_max = 0.00002; set yr[0:1]}
plot 'data1.dat' u 1:(A_max>B_max ? $4/A_max : $4/A_max) w l dt 1 lt rgb "red", 'data2.dat' u 1:(A_max>B_max ? $4/A_max : $4/A_max) w l dt 1 lt rgb "blue"
#-----------------------------------------------
unset yr
#-----------------------------------------------
# set horizontal margins for fourth column
set lmargin at screen left(4)
set rmargin at screen right(4)
# set horizontal margins for first row (bottom)
set tmargin at screen top(1)
set bmargin at screen bot(1)
stats "data1.dat" u 5 name "A"
stats "data2.dat" u 5 name "B"
if (A_max <= 0.0) {A_max = 0.00001; set yr[0:1]}
if (B_max <= 0.0) {B_max = 0.00002; set yr[0:1]}
plot 'data1.dat' u 1:(A_max>B_max ? $5/A_max : $5/A_max) w l dt 1 lt rgb "red", 'data2.dat' u 1:(A_max>B_max ? $5/A_max : $5/A_max) w l dt 1 lt rgb "blue"
unset multiplot
unset output
And the output is :
P.S. Apologies for long file but wanted to put all information here. Please let me know if/where it gets confusing.

How to plot into a histogram specific values from a file using Gnuplot

I'd like to plot two bars for a histogram, one depending on the first line of a file, while the other one depending on the second line. E.g., assuming to have a CSV file like this:
1 0.5
2 0.7
I want to plot a first bar blue of value 0.5 and a second bar red of value 0.7.
I've written the following script so far (I have a multiplot because I need to plot 4 figures of equal properties):
#!/usr/bin/env gnuplot
set term pngcairo enhanced size 1500,700
set output 'accuracy_plot.png'
set multiplot layout 1,4
set xlabel 'rounds' font ',16'
set ylabel 'mean' font ',16'
set xrange[1:2]
set yrange[0:1]
set style fill solid
set grid xtics lt 0 lw 1 lc rgb "#333333"
set grid ytics lt 0 lw 1 lc rgb "#333333"
set xtics font ',14'
set xtics autofreq 1
set ytics font ',14'
set key font ',12'
set title font ',20'
###
set title 'Q1'
plot "q1.csv" using 1:2 title '' with boxes linecolor rgb 'blue', \
"truth1.csv" using 1:2 title 'truth' with lines linewidth 3 linecolor rgb 'black'
###
set title 'Q2'
plot "q2.csv" using 1:2 title '' with boxes linecolor rgb 'blue', \
"truth2.csv" using 1:2 title 'truth' with lines linewidth 3 linecolor rgb 'black'
###
set title 'Q3'
plot "q3.csv" using 1:2 title '' with boxes linecolor rgb 'blue', \
"truth3.csv" using 1:2 title 'truth' with lines linewidth 3 linecolor rgb 'black'
###
set title 'Q4'
plot "q4.csv" using 1:2 title '' with boxes linecolor rgb 'blue', \
"truth4.csv" using 1:2 title 'truth' with lines linewidth 3 linecolor rgb 'black'
###
unset multiplot
I've tried solutions like "<(sed -n '1,1p' q1.csv)" but it didn't work.
Any idea?
You don't need to post all that settings for the tics, the labels and the multiplotting to show the problem.
You can use e.g. linecolor variable to select different line types depending on the value in the first column:
set terminal png enhanced
set output 'foobar.png'
set yrange [0:1]
set style fill solid
set linetype 1 lc rgb 'blue'
set linetype 2 lc rgb 'red'
plot 'q1.csv' using 1:2:1 with boxes lc variable notitle
Note, that the changes with set linetype aren't restored with reset, but you must restart gnuplot (version 5.0 will have a reset session option for this).
I changed every CSV in this form:
R1 R2
0.5 0.7
and my script:
#!/usr/bin/env gnuplot
set term pngcairo enhanced size 1500,700
set output 'accuracy_plot.png'
set multiplot layout 1,4
set xlabel 'rounds' font ',16'
set ylabel 'mean' font ',16'
set xrange[1:2]
set yrange[0:1.5]
set style fill solid
set grid xtics lt 0 lw 1 lc rgb "#333333"
set grid ytics lt 0 lw 1 lc rgb "#333333"
set xtics font ',14'
set xtics autofreq 1
set ytics font ',14'
set key font ',12'
set title font ',20'
set style data histograms
set style histogram columnstacked
###
set title 'Q1'
plot "q1.csv" using 1 lt 1 title columnhead, \
newhistogram lt 1 at 1, '' u 1 ti col, \
newhistogram lt 2 at 2, '' u 2 ti col, \
"truth1.csv" using 1:2 title 'truth' with lines linewidth 3 linecolor rgb 'black'
###
set title 'Q2'
plot "q2.csv" using 1 lt 1 title columnhead, \
newhistogram lt 1 at 1, '' u 1 ti col, \
newhistogram lt 2 at 2, '' u 2 ti col, \
"truth1.csv" using 1:2 title 'truth' with lines linewidth 3 linecolor rgb 'black'
###
set title 'Q3'
plot "q3.csv" using 1 lt 1 title columnhead, \
newhistogram lt 1 at 1, '' u 1 ti col, \
newhistogram lt 2 at 2, '' u 2 ti col, \
"truth1.csv" using 1:2 title 'truth' with lines linewidth 3 linecolor rgb 'black'
###
set title 'Q4'
plot "q4.csv" using 1 lt 1 title columnhead, \
newhistogram lt 1 at 1, '' u 1 ti col, \
newhistogram lt 2 at 2, '' u 2 ti col, \
"truth1.csv" using 1:2 title 'truth' with lines linewidth 3 linecolor rgb 'black'
###
unset multiplot
This is the result (with real values):

How to Create a Spider Plot in Gnuplot?

I would like to produce a spider (aka radar/star) plot using Gnuplot where different axes have independent scales. I am able to produce such a plot using OriginPro (commercial), but with Gnuplot I am only able to set a radar plot with uniform scale.
The (csv file) dataset looks like the following (first row is column labels):
# FEATURE, Product_A, Product_B, Product_C, Product_D
attribute_1, 2, 10, 7, 3.5
attribute_2, 1, 0.5, 3,4
attribute_3, 37, 58, 49, 72
attribute_4, 1985, 1992, 2006, 2010
attribute_5, 0.1, 0.5, 0.3, 0.8
and the plot I am looking for is this one: https://www.dropbox.com/s/uvqubzqvm6puhb8/spider.pdf -
As you can see each axis stands for a different attribute, and has its own scale.
I guess the Gnuplot starting code is:
set polar
set grid polar
set angles degrees
set size square
set style data filledcurves
But I don't know how to proceed. Any suggestions?
here's a hack attempt..
set nokey
set polar
set grid polar
set angles degrees
set size square
set style data lines
a1=0
a2=30
a3=100
a4=200
a5=300
set arrow nohead from 0,0 to first 10*cos(a1) , 10*sin(a1)
set arrow nohead from 0,0 to first 10*cos(a2) , 10*sin(a2)
set arrow nohead from 0,0 to first 10*cos(a3) , 10*sin(a3)
set arrow nohead from 0,0 to first 10*cos(a4) , 10*sin(a4)
set arrow nohead from 0,0 to first 10*cos(a5) , 10*sin(a5)
set xrange [-10:10]
set yrange [-10:10]
plot '-' using ($1==1?a1:($1==2?a2:($1==3?a3:($1==4?a4:($1==5?a5:$1))))):2 lt 2
1 4
2 8
3 6
4 9
5 5
1 4
Here is a suggestion for a "spider-plot" taken from my collection.
Since it uses data from a datablock instead from a file (because it's easier to address certain lines, e.g. via $Data[1]), therefore, it requires gnuplot >=5.2.0.
The actual data is in $Data and some settings for ranges and custom offset adjustments are in $Settings.
The number of axes is automatically adjusted if you add some more rows in $Data and $Settings. Data needs to be separated by whitespace, because the gnuplot function word(string,number) is used to extract some values.
I hope it is more or less self-explaining. Comments, report of bugs or improvements are welcome.
Code:
### spider plot/chart with gnuplot
# also known as: radar chart, web chart, star chart, cobweb chart,
# radar plot, web plot, star plot, cobweb plot, etc. ...
reset session
set size square
unset tics
set angles degree
set key top left
# Data
$Data <<EOD
SpiderData "Product A" "Product B" "Product C" "Product D"
Colors red green blue violet
"attribute 1" 2 10 7 3.5
"attribute 2" 1 0.5 3 4
"attribute 3" 37 58 49 72
"attribute 4" 1985 1992 2006 2010
"attribute 5" 0.1 0.5 0.3 0.8
EOD
HeaderLines = 2
# Settings for scale and offset adjustments
# axis min max tics axisLabelXoff axisLabelYoff ticLabelXoff ticLabelYoff
$Settings <<EOD
1 0 12 6 0.00 -0.02 -0.05 0.00
2 0 6 6 0.00 0.05 0.00 0.05
3 30 90 6 0.00 0.00 0.05 0.03
4 1980 2016 6 0.00 0.00 0.09 -0.02
5 0 1.2 6 0.00 0.05 0.00 -0.05
EOD
# General settings
DataColCount = words($Data[1])-1
AxesCount = |$Data|-HeaderLines
AngleOffset = 90
Max = 1
d=0.1*Max
Direction = -1 # counterclockwise=1, clockwise = -1
# Tic settings
TicCount = 6
TicValue(axis,i) = real(i)*(word($Settings[axis],3)-word($Settings[axis],2)) \
/ word($Settings[axis],4)+word($Settings[axis],2)
TicLabelPosX(axis,i) = PosX(axis,i/TicCount) + word($Settings[axis],7)
TicLabelPosY(axis,i) = PosY(axis,i/TicCount) + word($Settings[axis],8)
TicLen = 0.03
TicdX(axis,i) = 0.5*TicLen*cos(alpha(axis)-90)
TicdY(axis,i) = 0.5*TicLen*sin(alpha(axis)-90)
# Functions
alpha(axis) = (axis-1)*Direction*360.0/AxesCount+AngleOffset
PosX(axis,R) = R*cos(alpha(axis))
PosY(axis,R) = R*sin(alpha(axis))
Scale(axis,value) = real(value-word($Settings[axis],2))/(word($Settings[axis],3)-word($Settings[axis],2))
# Spider settings
set style arrow 1 dt 1 lw 1.0 lc -1 head # style for axes
set style arrow 2 dt 2 lw 0.5 lc -1 nohead # style for weblines
set style arrow 3 dt 1 lw 1 lc -1 nohead # style for axis tics
set samples AxesCount
set isosamples TicCount
set urange[1:AxesCount]
set vrange[1:TicCount]
do for [i=1:DataColCount] { # set linetypes/colors
set linetype i lc rgb word($Data[2],i+1)
}
set style fill transparent solid 0.2
set xrange[-Max-4*d:Max+4*d]
set yrange[-Max-4*d:Max+4*d]
plot \
'+' u (0):(0):(PosX($0,Max+d)):(PosY($0,Max+d)) w vec as 1 not, \
$Data u (PosX($0+1,Max+2*d)+word($Settings[$0+1],5)): \
(PosY($0+1,Max+2*d)+word($Settings[$0+1],6)):1 every ::HeaderLines w labels center enhanced not, \
'++' u (PosX($1,$2/TicCount)):(PosY($1,$2/TicCount)): \
(PosX($1+1,$2/TicCount)-PosX($1,$2/TicCount)): \
(PosY($1+1,$2/TicCount)-PosY($1,$2/TicCount)) w vec as 2 not, \
'++' u (PosX($1,$2/TicCount)-TicdX($1,$2/TicCount)): \
(PosY($1,$2/TicCount)-TicdY($1,$2/TicCount)): \
(2*TicdX($1,$2/TicCount)):(2*TicdY($1,$2/TicCount)) \
w vec as 3 not, \
for [i=1:DataColCount] $Data u (PosX($0+1,Scale($0+1,column(i+1)))): \
(PosY($0+1,Scale($0+1,column(i+1)))) every ::HeaderLines w filledcurves lt i title word($Data[1],i+1), \
'++' u (TicLabelPosX($1,$2)):(TicLabelPosY($1,$2)): \
(sprintf("%g",TicValue($1,$2))) w labels font ",8" not
### end of code
Result:
The answer by #george helped me figure out how to rearrange the dataset, in order to pick from it the corresponding attribute data.
Because I was also looking for different range scales for the different spider axes, in addition to #george's suggestion, I thought that an axis-specific normalisation to the common [0:1] range, would have the problem solved. The main modification is then related to the using field of the plot command.
The code is fairly lengthy, I'm sure it could be optimised. It could also be merged into a script or a simple C code, in order to let the user decide the number of axes (number of attributes), and the different ranges (min, max) for each specific axis.
The following example is for 5 attributes comparing 2 products. Here is shown the plot result image:
set nokey
set polar
set angles degrees
npoints = 5
a1 = 360/npoints*1
a2= 360/npoints*2
a3= 360/npoints*3
a4= 360/npoints*4
a5= 360/npoints*5
set grid polar 360.
set size square
set style data lines
unset border
set arrow nohead from 0,0 to first 1*cos(a1) , 1*sin(a1)
set arrow nohead from 0,0 to first 1*cos(a2) , 1*sin(a2)
set arrow nohead from 0,0 to first 1*cos(a3) , 1*sin(a3)
set arrow nohead from 0,0 to first 1*cos(a4) , 1*sin(a4)
set arrow nohead from 0,0 to first 1*cos(a5) , 1*sin(a5)
a1_max = 10
a2_max = 5
a3_max = 100
a4_max = 2020
a5_max = 1
a1_min = 0
a2_min = 0
a3_min = 50
a4_min = 1980
a5_min = 0
set label "(0:10)" at cos(a1),sin(a1) center offset char 1,1
set label "(0:5)" at cos(a2),sin(a2) center offset char -1,1
set label "(50:100)" at cos(a3),sin(a3) center offset char -1,-1
set label "(1980:2020)" at cos(a4),sin(a4) center offset char 0,-1
set label "(0:1)" at cos(a5),sin(a5) center offset char 3,0
set xrange [-1:1]
set yrange [-1:1]
unset xtics
unset ytics
set rrange [0:1]
set rtics (""0,""0.25,""0.5,""0.75,""1)
plot '-' using ($1==1?a1:($1==2?a2:($1==3?a3:($1==4?a4:($1==5?a5:$1))))):($1==1?(($2-a1_min)/(a1_max-a1_min)):($1==2?(($2-a2_min)/(a2_max-a2_min)):($1==3?(($2-a3_min)/(a3_max-a3_min)):($1==4?(($2-a4_min)/(a4_max-a4_min)):($1==5?(($2-a5_min)/(a5_max-a5_min)):$1))))) w l
1 8
2 3
3 67
4 2000
5 0.2
1 8
plot '-' using ($1==1?a1:($1==2?a2:($1==3?a3:($1==4?a4:($1==5?a5:$1))))):($1==1?(($2-a1_min)/(a1_max-a1_min)):($1==2?(($2-a2_min)/(a2_max-a2_min)):($1==3?(($2-a3_min)/(a3_max-a3_min)):($1==4?(($2-a4_min)/(a4_max-a4_min)):($1==5?(($2-a5_min)/(a5_max-a5_min)):$1))))) w l
1 6
2 1.5
3 85
4 2010
5 0.5
1 6
The following repo shows a spider chart with homogeneous scales. https://github.com/orey/gnuplot-radarchart
For your particular case, I would:
-Create functions that would normalize all data to fit in the diagram scale,
-Hide tge standard scale,
-Use arrows for the axis,
-Add points with labels for your particular scales and place them with your data functions.
I think inspiration can be found in the repo.

Resources