display values within stacked boxes of rowstacked histograms in gnuplot? - gnuplot

I am using gnuplot (Version 4.4 patchlevel 2) to generate rowstacked histograms, very similar to the example called "Stacked histograms by percent" from the gnuplot demo site at http://www.gnuplot.info/demo/histograms.html
I want to display the values of each stacked box within it.
I.e. I want to display the actual numerical value (in percent and/or the absolute number) of each box.
How can I do that?

How many numbers do you want to enter.
If it is just a few then have you tried
set label "label" at 2,3
If there are many then you can write a script to decide where to put the numbers - something like here
Plotting arrows with gnuplot
Don't know a way to do it by magic, although I am not very familiar with rowstacked histograms
Tom

Related

Default weighing criterion for gnuplot's 'lc palette'

I'm a novice in Gnuplot. Today I was plotting a simple txt file with two data columns, being the x and y coordinates of a cloud of points in the xy plane; I wanted to color them according to the position they occupied in the list, so I should have gone for something like:
plot "data.txt" u 1:2:0 lc palette
that produces what I want:
(desired plot)
By mistake, I omitted the "using" part of the command, so that I prompted:
plot "data.txt" lc palette
Now, the points still are plotted in the correct positions, so that gnuplot is automatically interpreting them as (x,y) coordinates... but the colors look like this:
(strangely colored plot)
I find this baffling since there's the possibility that I'm involuntarily highlighting some interesting feature of my data (which, by the way, consists of few iterations of a discrete recurrence for a set - the x=1.57 line you can see - of different initial conditions.
The question is: what criterion does 'lc palette' use to assign the parity I see to my points? What is its default behavior supposed to be in this case?
Thanks in advance!
EDIT: I don't know if it can be useful, but prompting 'show palette' I get:
palette is COLOR
rgb color mapping by rgbformulae are 7,5,15
figure is POSITIVE
all color formulae ARE NOT written into output postscript file
allocating ALL remaining color positions for discrete palette terminals
Color-Model: RGB
gamma is 1.5

Set label font size from data column in gnuplot

I'm trying to plot using labels with varying font size. For example:
plot "some_data_file" using 1:2:(20-$3) using labels font sprintf("Helvetica,%d",variable)
Or something to that effect. The label's font size should be 20 minus the value in the third column. This line doesn't work, but I think it displays what I'm trying to do. Any ideas?
Look at cities.dem demo on gnuplot.info for a way to do this.
I'll steal the solution there, modified for you:
plot "some_data_file" using 2:3:(sprintf("{/Helvetica=%d %s}",\
20-$4, stringcolumn(4))) with labels

gnuplot gives me strange plot look

I could not describe how the plot looks like so I just use "strange" as I have no idea why gnuplot gives me such a plot. Here is the thing I am trying to do.
I have a data file with two columns, the first column is the file name and the second is the size of each file. Each column is more than 2 million rows. I just want to plot the distribution of file sizes. Here is my code
set terminal postscript landscape enhanced mono dashed lw 2 "Times" 18
outputfile = "sizedist.ps"
set output outputfile
binwidth = 0.05
bin(x,width)=width*floor(x/width)
plot [0:3.5][]'sizedist.out' using (bin(log10($2/1024),binwidth)):(1.0) smooth freq with boxes t "Binsize=0.05 dex"
set terminal x11
Ideally, it should be a single Gaussian-like bar plot, but it has many other plots over-layed (see my attachment). Any expert on gnuplot knows why this happened?
This happens if some of your data in the frequency plot does not have well defined values (such as NaN, inf etc.).
Since you are using a logarithmic function in the plot, you have to be careful with data that has values <=0. I guess you have files with size=0. In this cases log10 just gives you NaN and this messes up the counting procedure of the frequency plot.
Include a condition to your plot to fix this. For example:
plot [0:3.5][]'sizedist.out' using ($2>0?bin(log10($2/1024),binwidth):0):(1.0) smooth freq with boxes t "Binsize=0.05 dex"

gnuplot print legend directly next to individual graphs

I want to project a 3D plot into a 2D plot. Assuming f(x,y) describes my 3D plot, I want to treat y as a parameter and simultaneously plot f(x,0), f(x,2), f(x,4), etc. in one 2D plot. Instead of going for different line/point styles and colors with a legend in a corner, I'd like to make each plot in the same style and place a label next to each individual line.
Is this even possible in gnuplot or would I have to fall back on something more complex?
I had a similar question recently. There is an option in the development version of gnuplot (4.7.0) that does this. You can change the position of line titles to be at the end/beginning of the line itself. If your plot looks like I imagine (sort of a contour plot) this may be what you want:
plot f(x,y) title 'f(x,y)' at end
Otherwise you may have to specify the labels and their positions manually:
help set label
for more info.

How to make an horizontal box-and-whiskers plot in gnuplot

How do you make an horizontal box-and-whiskers plot in gnuplot? Similarly to this one:
Gnuplot can easily be used to produce vertical box-and-whiskers plots with the 'candlesticks' and 'whiskerbars' keywords, but I have not managed to find any example of an horizontal candlesticks/box-and-whiskers horizontal plot produced via gnuplot online.
Example of a vertical plot produced by gnuplot:
example of a vertical box-and-whiskers plot http://www.cise.ufl.edu/~dts/cop3530/proj02/candlesticks.6.png
Gnuplot generally doesn't switch directions well... for example you can't plot rows instead of columns, and it's hard to make histograms (or any other kind of plot) go horizontal instead of vertical.
People have made horizontal histograms, however, and you might be able to modify the code found at this site.

Resources