How can I create a legend with whitespaces in the column header with autotitle? E.g. the first two lines of the data file:
T "x high" "x low"
0.1 3.14 0.0554
The legend should be:
T
x high
x low
Unfortunately gnuplot interprets it like this:
T
x
high
The quotes are simply ignored and the second column header is split into two. I couldn't find any information about this on the internet.
For me, which gnuplot version 4.6 the following works:
set key autotitle columnheader
plot 'file.dat' using 1:2 , '' using 1:3
and gives the legend
x high
x low
There is no problem with quoting.
Related
I am plotting data with y-errorbars on a pdfcairo terminal and have a problem to properly size the data points:
plot "test.data" u ($6) : 10 : 11 with yerrorbars pt 7 ps 0.5 t
ps 1 gives too large a point and decreasing ps gives strange results. Interestingly, on a windows terminal everything looks ok, but the pdfcairo terminal makes problems. What is wrong?
Hmm. I see a problem also but I do not know what causes it.
Workaround
Plot the data twice, once to show the error bars and once to show the variable size points. Here is a screenshot of the pdf output using gnuplot 5.4.4
set term pdfcairo
set output 'yerrorbar.pdf'
set sample 51
set xrange [0:1]
set key left reverse
plot '+' using 1:1:(0.2) with yerrorbar lc 'blue' pt 7 ps 0, \
'+' using 1:1:1 with points lc 'blue' pt 7 ps variable
I would like to place an arrow at the end of the axis labels (NOT on the plot). Currently I am using dashes (---) followed by greater than symbol (>) instead. Would prefer using arrows.
Thanks
Although the answer is a bit late, the easiest is probably to use the Unicode character U+2192 →
This works even with gnuplot 4.6.0 (2012). If your arrow is too small you can enlarge it with enhanced text mode which should work at least with gnuplot>=5.0.0 (2015).
Code:
reset
set xlabel "x-label --->\nx-label →\nx-label {/:Normal=20 →}"
set ylabel "y-label --->\ny-label →\ny-label {/:Normal=20 →}"
plot x
Result:
I'm new with gnuplot loops, and I don't know why is it crashing...
I want to make a plot with 10 different .txt data files and after that 10 different plot from these .txt-s. (Sorry for my english)
note: I am using win 8.1 -> I know I should use gnuplot with Ubuntu but that's the situation for now...
So here is my script:
cd'C:\RégiPC\asztal222\TDK\fittnessmodell\fittnessmodell\Incidencia s0 pk emel\001'
set title "Fitness előny nélkül pk=0.7+=0.03"
set term png size 1280,768
set key tmargin left
set xlabel "Idő"
set ylabel "Populációméret"
set output "Incidencia_N_10.png"
p for[i=0:9] 'Incidencia_'.i.'.txt' u 1:2 title 'N'.i
// here I want to do 10 different curves in one plot
unset output
do for[i=0:9]
{
set output 'Incidencia_minden_'.i.'.png'
p 'Incidencia_'.i.'.txt' u 1:2 title 'N'.i , 'Incidencia_'.i.'.txt' u 1:3 title 'nacd'.i,'Incidencia_'.i.'.txt' u 1:4 title 'nscd'.i,'Incidencia_'.i.'.txt' u 1:5 title 'nscdplusd'.i
unset output
} // in this do for loop I want to do 10 different plots from 10 different .txt files
Please help and sorry if it is too trivial...
Thank you and Happy New Year!!!!
Good evening sir!
I use Ubuntu 14.04 and your code works fine with some change listed below.
1.) If you want to comment something you should use # instead of //.
2.) A problem occurs in the do for loop. You accidentally put the braces into a new line which is incorrect according to my gnuplot (version 4.6). The correct way to use it:
do for [i=0:9] {
set output 'Incidencia_minden_'.i.'.png'
p 'Incidencia_'.i.'.txt' u 1:2 title 'N'.i , 'Incidencia_'.i.'.txt' u 1:3 title 'nacd'.i,'Incidencia_'.i.'.txt' u 1:4 title 'nscd'.i,'Incidencia_'.i.'.txt' u 1:5 title 'nscdplusd'.i
unset output
}
After these changes the code don't make any error or crash in my computer.
I don't know if this works on Windows. You have to try it. :)
I've seen several examples of labels in gnuplot (where two columns define the 2D plot, and a third column is used to make labels that apply to the points in the 2D plot) but I can't seem to get them to work on my gnuplot.
We have 4.0, and it seems like the standard examples are for 4.2 and higher.
Is there any way to use three columns to define a 2d plot with labels in gnuplot 4.0?
I've tried things like:
plot "datafile.gnu" using ($3+3):($4+3):2 with labels, "datafile.gnu" using 3:4 with lines
plot "datafile.gnu" using 3:4:2 with labels, "datafile.gnu" using 3:4
plot "datafile.gnu" using 3:4 with lines, '' using 2 with labels
....
3 & 4 are columns for the x & y and 2 is the column containing the label I want at each point.
No matter what I try I'm getting errors back.
gnuplot4.0 is ancient. As such, I don't have access to a copy of it -- However, you might try something like this:
!awk '{printf "set label \"%s\" at %f,%f point\n",$3,$1,$2 }' datafile.gnu > labels.gnuplot
load "labels.gnuplot"
I'm using aquaterm 1.0.1 through octave and gnuplot - on my mac - to generate printable plots. When aquaterm generates my plots, it has a habit of cutting off or cropping all of the titles and axis labels.
Is there another imaging program that works with octave that won't have this problem? Or are there other fixes I haven't thought of?
I prefer the plot results from aquaterm more than x11. I wrote an m-file script, which is really a kludge, to fix this problem so aquaterm is useable. It seems like the title and xlabel text strings are written one line too high and too low in the figure window. Note -this script doesn't change the ylabel. If the magnitude of the printed y-coordinate values are too large, it tends to move the ylabel off the left side of the page. Anyway here is my kludge, just run it after all figures are complete.
function fixAxes
%---------------------------------------
%// Kludge to fix scaling of all figures
%// until GNU or I can find real fix.
%// Octave3.2.3 computes the scaling wrong
%// for this mac, such that the title
%// and xlabel are not displayed.
%---------------------------------------
s = get(0,'showhiddenhandles');
set(0,'showhiddenhandles','on');
newpos = [0.13 0.135 0.775 0.75]; %// default is [0.13 0.11 0.775 0.815]
figs = get(0,'children');
if (~isempty(figs))
for k=1:length(figs)
cax = get(figs(k),'currentaxes');
pos = get(cax,'position');
if ~(pos(1) == newpos(1) && ...
pos(2) == newpos(2) && ...
pos(3) == newpos(3) && ...
pos(4) == newpos(4))
set(cax,'position',newpos);
set(0,'currentfigure',figs(k));
drawnow();
endif
endfor
endif
set(0,'showhiddenhandles',s);
%---------------------------------------
endfunction
%---------------------------------------
While I don't know why aquaterm cuts of parts of your plot, you can try using X11 terminal. In Octave, you can say setenv GNUTERM 'x11' to do so.