How to specify color of multiplot title - gnuplot

This might be a silly question, but I can't figure out how to specify the (font-) color for the title in a multiplot.
gnuplot> set multiplot layout 2,1 title "Title" font ",14" tc rgb "blue"
^
invalid or duplicate option

This feature does not seem to be supported currently "out of the box".
However, it looks like that the reason is just because the color specification is not parsed. To be more specific, the function multiplot_start in src/multiplot.c parses only font name,size so the remaining tokens in your example cause the invalid or duplicate option error.
A bit dirty solution would be to add this feature manually. It seems that to this end, one needs to do the following:
add #include "misc.h" at line 50 of src/multiplot.c
at line 255 of the same file, add
-
if (equals(c_token,"tc") || almost_equals(c_token,"text$color")) {
parse_colorspec(&(mp_layout.title.textcolor), TC_VARIABLE);
continue;
}
Then after running the standard ./configure ... && make install commands, your example produces in this customized version of Gnuplot the desired blue title...

Related

Is there anyway to change colour of plots in Haskell GNUPlot.Simple package

I'm using GNUPlot.Simple for Haskell and am trying to change the colour of my plots.
Specifically when I use the code:
plotListsStyle [][ ((PlotStyle {plotType = Lines, lineSpec = CustomStyle [ PointSize 0.1, LineTitle "First "] }) , ( zip [0..10] [0..10]))]
I want to change the colour of the plot.
I tried looking at the source code here https://www.stackage.org/haddock/nightly-2022-01-23/gnuplot-0.5.6.1/Graphics-Gnuplot-Simple.html, but couldn't figure out if there is anyway to do this.
Does anyone know how to do this or can recommend an alternative?
Thanks
From a quick look at the summary page in your link, it seems that the Simple variant of the Haskell wrapper does not provide a means to access the "linecolor" attribute of lines, points, etc. So you get only the default colors.
On the other hand, if the script it produces is fed to a standard build of gnuplot then the program will on entry read a system- and/or user- initialization script. So you could change the default line colors in that initialization script and the change would affect subsequent execution of scripts produced by your Haskell wrapper.
For example, if you want the color of the first plot to be green and the second plot cyan, you could place the lines
set linetype 1 linecolor "forest-green"
set linetype 2 linecolor "cyan"
in the file ~/.gnuplot. That would replace the first two colors of the default sequence.

Strange behaviour in gnuplot for label with Arial font face in pdfcairo terminal

I am obtaining a strange behaviour on gnuplot 5.2.2 pdfcairo terminal with a label composed of several lines and attempted to be printed align to center. The label is the signature for my plots, it is composed of my name (first line), my institution (second line) and the date, obtained from time(0) and strftime.
In a multiplot script I noticed that the date (3rd line) was printed align to left while the other two line were printed align to center as intended. Then I placed the set label instruction before the first plot was called so that the label is printed two times. Then, in the first call, date was aligned to left but in the second call the date was aligned to center, as intended. Same happens if the align to right mode is intended. However if the strftime string is substituted by a regular string "foo" then alignment works fine.
This behaviour only happens if font is set to Arial and if the terminal is set to pdfcairo. If font is set to Ubuntu (or Times) or if the terminal is set to pngcairo then all calls print the label truly align to center.
A minimal workable example is:
set terminal pdfcairo enhanced color font "Arial,"
set output "prueba.pdf"
set multiplot layout 1,2
set colors podo
Cadena_firma="Martin-Olalla JM\nUniversidad de Sevilla\n".strftime("%Y/%m/%d",time(0))
set label 1 at screen 0.85,0.25 Cadena_firma noenhanced center font "Arial,10" tc rgb '#9d2235' front
set yrange [-2:2]
plot sin(x) lc 3
plot cos(x) lc 3
I attached the output, highlighting the weird printing of the date.
This is only happening in one of the computers I handle. It is easily solvable by changing the font. Nonetheless I am curious and it might be interesting for others.
There have been multiple reports of font problems that all appear to trace back to bad pango/cairo library versions. Some of the problems are OS-specific and some are font-specific. So there are probably multiple issues involved. Here are some tracker items:
https://gitlab.gnome.org/GNOME/pango/issues/422
and
https://sourceforge.net/p/gnuplot/bugs/2052/

Error bars drift away from the main bars

I'm trying to draw bar graphs with error bars. Here is my script,
set term pngcairo
# ... some setup code
set style data histogram
set style fill solid 1.00 border
set style histogram gap 1 errorbars lw 1
set ytics 800
set output "thttpd.png"
plot 'thttpd.dat' using 2:3:xtic(1) title col(2)
My data is like this,
File_size Original_thttpd std_dev priv std_dev
16 617.525151042 46.4794798061 623.229175781 17.4696494741
32 1094.72792871 36.709731068 1105.89255892 21.3383446583
64 1736.16701074 14.9846134633 1738.41502295 23.9069441408
......
I got figure,
As you can see, the error bars are separated from the main bar. I'm using gnuplot 5.2. Can anyone tell me how to fix this problem? Thanks!
That looks like a bug that was fixed sometime between version 5.2.2 and 5.2.4.
The program failed to recognize that use of "title col(2)" in your plot command necessarily implies the presence of an extra row of data containing column headings. You can bypass this failure by adding the command
set key autotitle columnhead
That will ensure that the program knows about the row of column header labels
even if the autotitle feature isn't used for a particular plot.

Gnuplot nested do loop and plotting on the same graph

Hi I'm using gnuplot to create a large number of graphs. To save myself work I've written a script that tries to plot all possible graphs.
#!/usr/bin/gnuplot
reset
is_missing(x)=system("./ismissing.sh ".x)
set terminal post eps enhanced color
set key inside right top vertical Right noreverse enhanced autotitles box linetype -1 linewidth 1.000
set grid
models="Cebeci-Smith Baldwin-Lomax Spalart-Allmaras Launder-Sharma Chien"
files="./CebeciOut/ ./BaldwinOut/ ./SpalartOut/ ./LaunderOut/ ./ChienOut/"
xgrid="35000 70000 140000 280000 560000"
# Plot grid convergence Spalart
do for [f=1:words(files)]{
set output sprintf('%s%s',word(files,f),'ZPGGridConvergence.eps')
set title sprintf("%s%s",word(models,f), " ZPG Grid Convergence")
set xlabel "N_y"
set ylabel "C_f Final"
print f
do for [i=1:words(xgrid)]{
filename=sprintf("%s%s%s%s",word(files,f),'yconv_',word(xgrid,i),"x")
if(is_missing(filename)==0){
plot filename using 1:2 title sprintf("%s%s",word(xgrid,i), " X Gridpoints") with linespoints
}
}
}
Unfortunately I have a problem, after one full iteration the script fails, ie f is never made 2 despite the first plots completing successfully. The error given is
cannot open file; output not changed
line 25: util.c: No such file or directory
which I haven't managed to decipher. Any help would be much appreciated. Also is there a way to use replot in this loop given I haven't already created a plot.
Thanks
"files" are actually dirs in your code.
If you want to place the output in a subdir, then make sure that it exists and is writable.
gnuplot cannot create subdirs automatically. You can add system("mkdir -p ".word(files,f)) ( on linux/unix) in your code to create the directory if needed.

Is it possible to set the "linetype" in gnuplot while using "linecolor variable"?

I have a tab-separated data file containing a number of (double-blank-line-separated) datasets and I want to plot a line for each of them. I want to be able to set the linetype (by this I'm referring to solid/dashed/dotted). I want each line to be a different color.
I can plot them all different colors using this:
plot 'example.dat' using 1:2:(column(-2)) with lines linecolor variable
And I can set the linetype but plot them all the same color using this:
plot 'example.dat' using 1:2:(column(-2)) with lines linetype 5
But when I combine them, the linetype is not what I set it to (in this case I just get a solid line).
plot 'example.dat' using 1:2:(column(-2)) with lines \
linetype 5 linecolor variable
Is there a way to achieve this?
I'm using gnuplot 4.6, tried with the x11 and postscript terminals.
This looks like a bug to me. Unfortunately, I don't think too many gnuplot devs hang out on StackOverflow, so we might not ever find out. (I would encourage you to submit a bug report though and keep me updated on any progress that might be made)...
If you're really using column(-2) to pick out the colors, the problem becomes a lot easier and you should be able to do that using plot iteration (as long as you know an upper limit on the number of datasets).
NDSET=3 #This will issue a warning if NDSET is too big, but will still work.
plot for [IDX=0:NDSET] 'example.dat' index IDX using 1:2 with lines linetype 5 linecolor IDX+1
The indexing starts from 0 and corresponds to column(-2). Linecolor 0 isn't defined (I don't know why gnuplot uses two different conventions here -- I suppose because in theory the colors corresponding to any particular linestyle are terminal dependent, so it doesn't really matter too much anyway...)

Resources