Put histogram side-by-side - gnuplot

I want to group an histogram rowstacked in gnuplot similar to this image:
I have these 2 files where the data from the histogram comes from:
#Round-robin
Input West-Virginia ChicagoI ChicagoII California
1500 28 25 28 19
3000 30 24 25 21
4500 28 28 25 19
6000 34 25 23 18
#Min-makespan
Input West-Virginia ChicagoI ChicagoII California
1500 34 20 30 17
3000 33 30 21 16
4500 31 23 38 9
6000 42 21 38 0
plot for [i=2:5] 'cloudusage-roundrobin.dat' using i:xtic(1), \
for [i=2:5] 'cloudusage-minmakespan.dat' using i:xtic(1)
1 - My plot instruction stack both histograms, instead of having them side-by-side. How I put them side-by-side, and also with the 2 xx labels ?

You must use newhistogram to start a new histogram. In order to use the same linetype, you must give the second call to newhistogram the option lt 1:
reset
set style data histogram
set style histogram rowstacked title offset 0,-1
set bmargin 4
set boxwidth 0.9
set style fill solid border lt -1
set key autotitle columnheader horizontal
plot newhistogram 'Cluster 1', \
for [i=2:5] 'cloudusage-roundrobin.dat' using i:xtic(1),\
newhistogram 'Cluster 2' lt 1, \
for [i=2:5] 'cloudusage-minmakespan.dat' using i:xtic(1) notitle
Result with 4.6.4:

Related

plot 10 line sof 1000 values on gnuplot

I have a data file with 10 lines with 1000 values each line and I'm trying to plot this values with this script
#!/usr/bin/gnuplot -persist
plot "data.dat" using [1:1000] title "" with lines
but I get this error
plot "data.dat" using [1:1000] title "" with lines
^
"./plot.sh", line 3: invalid expression
How can I indiate a interval form the first value to the 1000 value?I't posible to set a diferent random clor to every line?
As #vaettchen pointed out, gnuplot wants data in columns and plotting rows is not straightforward. So, best would be if your data was transposed. Unfortunately, gnuplot has no function to transpose data. So, you have to use external tools to transpose your data.
Although, if your data is 10 lines with 1000 values each, i.e. a strict 10x1000 matrix, you could do something with gnuplot only (see below).
However, if your data is not a strict matrix, e.g. one line has more or less values or one value missing the method below won't work.
The following example (just 5 lines with 7 values each) illustrates plotting columns and plotting rows.
### plotting columns and rows
reset session
set colorsequence classic
$Data <<EOD
11 12 13 14 15 16 17
21 22 23 24 25 26 27
31 32 33 34 35 36 37
41 42 43 44 45 46 47
51 52 53 54 55 56 57
EOD
# get the number of rows
stats $Data u 0 nooutput
RowCount = STATS_records
# do the plot
set multiplot layout 1,2
set title "Plotting columns"
set xlabel "Row no."
set xtics 1
# plot all columns from 1 to *(=autodetection)
plot for [i=1:*] $Data u ($0+1):i w lp pt 7 not
set title "Plotting rows"
set xlabel "Column no."
# plot all rows
plot for [i=0:RowCount-1] $Data matrix u ($1+1):0 every :::i::i w lp pt 7 not
unset multiplot
### end of code
Which results in:

GNUPLOT LINUX Value y-axis near every point of a graph

I need to do a graph with gnoplot linux where on x-axis there are a date and on y-axis value of ok, ko and warning.
I've written the following code
#!/usr/bin/gnuplot
reset
unset title
set xlabel "Date (day/month)"
set ylabel "num Instance"
set yrange [0:40]
set term png large
set output "graph2.png"
set grid
set xdata time
set timefmt "%d/%m"
set format x "%d/%m"
plot \
'input.dat' using 1:2 with points pointtype 11 linecolor rgb "#00FF00" ti 'OK',\
'input.dat' using 1:3 with points pointtype 11 linecolor rgb "#ff0000" ti 'KO',\
'input.dat' using 1:4 with points pointtype 3 linecolor rgb "#ffed00" ti 'Warning'
with this input file
#date ok ko warning
06/02 1 30 3
07/02 5 14 16
08/02 30 15 14
09/02 9 14 9
10/02 7 30 3
11/02 2 7 21
12/02 30 12 15
13/02 10 15 14
14/02 24 14 16
15/02 20 12 15
and the graph is this
new_graph
Now I've to insert, near every point, also a value of y-axis.
Any idea?
I appreciate your help and thank you in advance

How set point type from data in gnuplot?

How set point type from data in gnuplot?
gnuplot script:
set terminal pngcairo size 640,480
set output "points.png"
set style data points
set auto x
set autoscale x
unset colorbox
plot 'test.data' using 2:1 with points notitle
test.data
32 35 8
34 34 6
36 28 1
34 32 2
28 30 7
38 30 9
34 29 2
35 36 9
39 34 3
31 33 9
28 31 6
35 30 5
33 41 4
32 37 3
how get point type from 3 column?
plot 'gnuplot.data' using 2:1 with points pt (:3) notitle // error
abstraction example:
need:
gnuplot Version 4.6 patchlevel 4
There is no option to select the point type from the data file based on a column (equivalent to linecolor variable, pointsize variable or arrowstyle variable). Basically you have two options:
Iterate over all possible point types (which you can extract with stats if this should be variable) and for each number plot only those points which match the current point type:
stats 'test.data' using 3 nooutput
unset key
set style data points
plot for [i=STATS_min:STATS_max] 'test.data' using 2:($3 == i ? $1 : 1/0) lt 1 pt i ps 2
Use the labels plotting style and a sequence of unicode point symbols from which you select using the value from the third column as index. (use e.g. http://www.shapecatcher.com or http://decodeunicode.org/en/geometric_shapes to find suitable symbols)
unset key
set encoding utf8
symbol(z) = "•✷+△♠□♣♥♦"[int(z):int(z)]
plot 'test.data' using 2:1:(symbol($3)) with labels textcolor lt 1

How to remove palette colors heatmap

Is possible if heatmap palette(small rectangle on the right) to be removed?
this is my data
a b c
1 181 80 121 10 34 20
2 18 20 17 20 13 20
3 12 20 5 30 20 20
this is my gnuplot script
set term pos eps font 20
unset key
set nocbtics
set palette rgbformulae -7, 2, -7
set title "Faults"
set size 1, 0.5
set output 'heatmap2.eps'
YTICS="`awk 'BEGIN{getline}{printf "%s ",$1}' 'data2.dat'`"
XTICS="`head -1 'data2.dat'`"
set for [i=1:words(XTICS)] xtics ( word(XTICS,i) i-1 )
set for [i=1:words(YTICS)] ytics ( word(YTICS,i) i-1 )
set for [i=1:words(XTICS)] xtics ( word(XTICS,i) 2*i-1 )
plot "<awk '{$1=\"\"}1' 'data2.dat' | sed '1 d'" matrix every 2::1 w image, \
'' matrix using ($1+1):2:(sprintf('%d', $3)) every 2 with labels
I want to remove the palette because I adjust the ploting colors by percentage of my data. So, I guess the palette on the right my table is now use anymore. Thanks
That is the colorbox. Just use
unset colorbox
to remove it.

add horizontal line histogram gnuplot

I would like to add a horizontal line in my histogram in gnuplot, is that possible?
My histogram has on the x axis: alea1 alea 2 alea3 nalea1 nalea 2 nalea 3
and the y axis goes from 0 to 25.
At 22, I want to add a horizontal line that goes all the way across from one end to the other end of the histogram.
Try adding
, 22 title ""
at the end of your plot command. Works for my test data (file "histo"):
# Year Red Green Blue
1990 33 45 18
1991 35 42 19
1992 34 44 14
1993 37 43 25
1994 47 15 30
1995 41 14 32
1996 42 20 35
1997 39 21 31
plot "histo" u 2 t "Red" w histograms, "" u 3 t "Green" w histograms, "" u 4 t "Blue" w histograms, 22 title ""
(taken from Philip K. Janert, Gnuplot in Action)
The typical way to add horizontal and/or vertical lines is with an arrow
set arrow from x1,y1 to x2,y2 nohead linestyle ...
For a horizontal line, y1 and y2 will be the same. From your question, I'm a little unsure what you mean by "at 22", but I'm guessing you mean that you want to plot the line y=22 on top of your histogram. If that's the case, try this (before your plot command).
set arrow from graph 0,first 22 to graph 1,first 22 nohead lc rgb "#000000" front

Resources