I'm trying to print stacked histogram from gnuplot into black and white png. By this I mean I would like each region in the bar to be hatched or checked alongside the legend on the side; that way when it's printed people can still identify the regions.
I've tried the following but it just leaves me with big black blobs!
set term pngcairo mono size 750, 300
set output \"pies/interesting.png\"
set style data histograms
set style histogram rowstacked
set boxwidth 1 relative
set style fill solid 1 border -1
set yrange [0:100]
set ytics 10
set datafile separator \",\"
plot './functions-$MODE.csv.t' using 1 t \"\", for [i=9:13] '' using (100.*column(i)/column(15)) ti column(i)
How do I make my regions hatched?
Apologies for answering my own question....I've realised that a stacked histogram behaves like a normal histogram: thus if I use the styles found on this page: http://gnuplot.sourceforge.net/demo/fillstyle.html I can customise to how I would like: setting "set style fill pattern border" :
set term pngcairo mono size 750, 300
set output \"pies/interesting.png\"
set style data histograms
set style histogram rowstacked
set boxwidth 1 relative
set style fill pattern border
set datafile separator \",\"
plot './functions-$MODE.csv.t' using 1 t \"\", for [i=9:13] '' using (100.*column(i)/column(15)) ti column(i)
Results in the desired effect.
Related
I have a bivariate histogram plot created using bar3. I'm trying to change the color of the bars that have a height less than a certain threshold, but to no avail. I got this code:
h = bar3(dataSample, 0.5);
for n=1:numel(h)
cdata=get(h(n),'zdata');
set(h(n),'cdata',cdata,'facecolor','interp')
end
I can't figure out how to make the plot look like the one below, where the bars less than say 0.001 are gray:
Any ideas?
here's how:
z=peaks(20);
h=bar3(z)
for n=1:numel(h)
cdata=get(h(n),'zdata');
set(h(n),'cdata',cdata,'facecolor','interp')
end
colormap([0.5.*ones(128,3); parula(128)]);
I've arbitrarily decided to cut the colormap in the middle, first 128 intensities as gray the next 128 intensities in color. you can cut it however you want. You can find the threshold you want by setting the colormap binning (say to 256 bins) and the place in that partition below which it'll be gray.
I know that I can set the color of gridlines using:
pax = gca;
pax.GridColor = 'black';
But the gridlines are still a faint grey. I would like to make them darker. Is there a way to make the gridlines bold?
Note I do not want to make the gridlines thicker, I just want to make them darker that the faint grey that seems to be the automatic when using black
I am using polar plots and when I print them, the grids are almost too faint to see.
You need to modify the GridAlpha property as well so that the grid lines are actually opaque. The default value is 0.15 so even though they are black they appear gray since they are transparent. You'll want to use a GridAlpha value of 1 .
pax.GridAlpha = 1
I work with in-house benchmark tool. I use gnuplot (gnuplot 4.6 patchlevel 4) for visualization.
I need to represent results (method execution times for several runs) as stacked line chart, something like this:
Here is an excerpt from my .tsv data file:
Run MethodA MethodB MethodC
1 192 171 152
2 227 178 161
...
10 229 161 149
And the script I'm using:
#!/usr/bin/gnuplot -p
reset
clear
set terminal png size 640,480
set output "timings.png"
set key top left outside horizontal autotitle columnhead
set title "Third-party REST calls"
set xlabel "Run (ordinal)"
set xtics nomirror scale 0
set ylabel "Time (milliseconds)"
set ytics out nomirror
set grid ytics lt 0 lw 1 lc rgb "#bbbbbb"
set style data histogram
set style histogram rowstacked
set style fill solid border -1
set boxwidth 0.75
plot "timings.tsv" using 2:xticlabels(1) , "" using 3, "" using 4
I get the following result:
Yes, it's not a line chart but histogram (I need to represent percentage of execution time of each method). I need slightly different result (the same histogram, not with boxes but with lines which connect boxes tops and with filling below lines), like this:
I'm aware of approach with filledcurve's (for instance, described there Creating a Filled Stack Graph in GNUPlot), but in that approach you need to sum values explicitly.
Is it possible to draw filled areas instead of boxes via gnuplot, e.g. convert histogram into stacked line chart?
You do need to sum values explicitly, but this is not a big issue. You can script it easily:
firstcol=2
cumulated(i)=((i>firstcol)?column(i)+cumulated(i-1):(i==firstcol)?column(i):1/0)
plot "file.dat" using 1:(cumulated(4)), "" using 1:(cumulated(3)), "" using 1:(cumulated(2))
I have a CSV file with a data, and I need to plot a histogram (bars actually) using the data from given file. However, labels at axis X need to have Polish letters, for instance ąęćżźśłóń (or, uppercase, ĄĘĆŻŹŚŁÓŃ). I have already set the encoding with set encoding iso_8859_1 but still, the result does not look like what I want:
Here is my gnuplot script:
#!/usr/bin/gnuplot
set encoding iso_8859_1
set datafile separator "\t"
set termoption enhanced
set terminal postscript eps size 5.5, 5.62 enhanced color font 'Verdana,20' linewidth 2
set output '2008.eps'
unset key
set xtics nomirror rotate by -45 scale 0 font ",15"
set style data histogram
set boxwidth 0.2
set grid y
set yrange [ * : 20000]
set style fill solid border
plot '2008.csv' using 2:xticlabels(1) with boxes linecolor rgb "#00FF00", \
'' using 0:2:2 with labels center offset 0,1 notitle
And my data file:
Województwo Suma
Dolnośląskie 4997 4997
Kujawsko-Pomorskie 10710 10710
Lubelskie 8978 8978
Lubuskie 4631 4631
Łódzkie 12609 12609
The question is: what do I need to do to have Polish letters on axis X, and in a plot title (which is not available here, but I would like to add it later)? Thank you.
You should probably use UTF-8. Here's what I did:
set terminal epscairo enhanced color dashed rounded size 5.5, 5.62
set encoding utf8
set output '2008.eps'
unset key
set xtics nomirror rotate by -45 scale 0 font ",15"
set style data histogram
set boxwidth 0.2
set grid y
set yrange [*:20000]
set style fill solid border
plot '2008.csv' using 2:xticlabels(1) with boxes linecolor rgb "#00FF00", \
'' using 0:2:2 with labels center offset 0,1 notitle
(I copied the data from your question, which is in UTF-8 format but doesn't contain tab characters, so I didn't use set datafile separator "\t".)
This gave me the following result.
I'm using the epscairo terminal because it uses the pango library for rendering text which is based on UTF-8.
I have a file with two columns
9 5
10 3
11 0
12 25
13 50
14 80
etc
What is the best way to plot bar char using gnuplot? Is using subprocess with gnuplot the best way? Ideally the graph should be in .pdf and in png as I want to put these on a website later on.
I would really appreciate your input/advise.
Here is an example, how to plot a bar chart with gnuplot using the plotting style with boxes
set terminal pngcairo size 1000,800 font ',12'
set output 'output.png'
set xlabel 'xlabel' font ',18'
set ylabel 'ylabel' font ',18'
set boxwidth 0.9
set style fill solid 0.3
set offset 0.5, 0.5, 10, 0
plot 'data.txt' with boxes linewidth 3 title ''
With the data you showed, this gives the following output image: