I have x-label range like this: 2.0237*e^10 to 15.055*e^10.
Now when I draw the graph then X-label values overlap.
How can I manage this without changing font size?
use "set xtics" to define a larger distance between the xlabel major tics.
You can also use "set format x " to define a more suitable format for the x-axes:
For example:
This draws the xlabel tics only at 2*e^10, 4*e^10, 6*e^10...
set xtics 2E10
This will display the label tics in a more compact form:
set format x "%1.0E"
You might also find this very helpful:
http://heim.ifi.uio.no/inf3330/scripting/doc/gnuplot/Kawano/tics-e.html#3.1
Related
What is wrong with this?
set ylabel 1.0,0.0
set ylabel "{/:Italic M}" font "Allert,12"
The error is
unexpected or unrecognized token
Thank you
It would help to make your question a little more explicit about what you intend to do.
Guessing from your code, possibly you want to have italic M label with an offset of (1,0). This would write
set ylabel "{/:Italic M}" font "Allert,12" offset 1,0
Indeed the first number in offset will set the distance between y-axis and label. What you were missing is simply this offset keyword in the first line :
set ylabel offset 1.0,0.0
If you do
gnuplot>?set xlabel
Syntax:
set xlabel {"<label>"} {offset <offset>} {font "<font>{,<size>}"}
{textcolor <colorspec>} {{no}enhanced}
{rotate by <degrees> | rotate parallel | norotate}
show xlabel
It seems you cannot give x,y positions to the labels. What you can do is give it dx,dy offsets:
> set ylabel "{/:Italic M}" font "Allert,12" offset dx,dy
Hope this helps.
I want to plot some stockpile data.
The data is located in a csv-file and I already got an almost accurate plot, so reading from file isn't the problem.
set terminal pdf
set output "gnuplot/".MATNUM."-2012.pdf"
set datafile separator ";"
stats 'Stock-2012.csv' every ::4::18 using MATNUM nooutput
set border 3
set tics nomirror
set xzeroaxis
set xrange[0:14]
set xtics 1,1,13
set xtics rotate 90
set ylabel MATUNIT
maxplot = sprintf("Amount max:\n%.2f ".MATUNIT, STATS_max)
plot 'Stock-2012.csv' every ::4::18 using ($0+1):MATNUM:xticlabels(2) with linespoints title "Amount", STATS_max with lines lc rgb 'blue' title maxplot
Where MATNUM and MATUNIT are commandline arguments, representing materialnumber (which is the columntitle in the datafile) and the unit in which the material is measured.
The x-values in my datafile are decimals, but gnuplot seems to cut off the fractional digits. For example 12,98 (commata are used as decimal separator, because it's a german stockpile) results in a datapoint at y=12.
I'm not sure but I think this happens only at the maximum and minimum y-value, as STATS_max is an integer every time.
What can I do to get my points at the right y-value?
Unfortunately you did not show any data from you file, but I guess you are using commas as decimal separators. In that case you need to set the right decimal sign for reading the input. You can use e.g.
set decimalsign locale
or use an explicit locale (this must be installed)
set decimalsign locale "de_DE.UTF-8"
Note, that setting an explicit character with set decimalsign ',' does not work because it usually affects only the output format of e.g. tics, but not the input behaviour.
I want to plot a function/dataset, where the secondary x-axis is a function of the primary x-axis, e.g. 1/x (non-linear). The reason for this is that they are both meaningful parameters. I can set the range correctly by using my "function", however, values in between are different. The following figure shows what is wrong:
What is wrong here, is that the x2-axis get linearly ticced (is that proper English?). Example: the tic opposite to 1.6 is now 0.7, but should be 0.625 for this case.
Script to reproduce this:
xmin=1.
xmax=2.
set xlabel "x"
set xrange [xmin:xmax]
set x2tics
set x2label "1/x"
set x2range [1/xmin:1/xmax]
plot x
Is a fancy general way to change the axis-scaling/labeling, other than logarithmic?
You can use a do for approach to loop through a manual label setting (set x2tics add). Here's the edited minimal example you provided (see comments in the script for explanations):
xmin=1.
xmax=2.
inc=0.2 # for more control over the tics
f(x)=1./x # Function that defines the secondary axis
fplot(x)=x # Function that is plot
set xlabel "x"
set xrange [xmin:xmax]
set xtics xmin,inc,xmax # specify the actual location for xtics, too
ntics = (xmax-xmin)/inc + 1 # calculate the number of tics
inc2 = (f(xmin)-f(xmax))/(ntics-1) # calculate increment for x2tics
fmin=f(xmin); fmax=f(xmax)
set x2tics fmin,-1*inc2,fmax # set x2tics, labels will be rewritten
# the following loops through the number of tics
# the <set x2tics add ("x2" x2)> command will be repeated
# use arithmetic to calculate the values and the locations
# you need <sprintf> to convert the tic label number into a string
do for [i=1:ntics+1] {
xtic=xmin+(i-1)*inc
x2ticpos=f(xmin)-(i-1)*inc2
set x2tics add (sprintf("%.3g",f(xtic)) x2ticpos)
}
set x2range [f(xmin):f(xmax)]
set yrange[fplot(xmin):fplot(xmax)] # you should also specify the yrange, to avoid surprises
plot fplot(x)
And the plot you'll get is this:
I am trying to use gnuplot to plot the graphene band structure as both surfaces and a countour plot at the base, set with set contour base, but I can't get rid of some axis lines and the plane where the contour is drawn is too far away from the surfaces when I place them in the adequate viewing angle.
Here is the code to plot the graph
# Setting ranges and function parameters
set xrange [-.55:.55]
set yrange [-1:1]
t=-3.033 s=0.129 a=1.43 * sqrt(3)
# Auxiliary functions
kx(x,y) = (2*pi/a) * (cos(pi/6)*x + sin(pi/6)*y) ky(x,y) = (2*pi/a) * (cos(pi/6)*x - sin(pi/6)*y)
w(x,y) = sqrt(1+4*cos(0.5*sqrt(3)*kx(x,y)*a)*cos(0.5*a*ky(x,y)) + 4*(cos(0.5*ky(x,y)*a))**2)
#functions to be plotted
e(x,y) = (t*w(x,y))/(1+s*w(x,y))
e_estrela(x,y) = (-t*w(x,y))/(1-s*w(x,y))
# Setting up 3D plot appearance
set hidden3d
set contour base set cntrparam levels discrete 0,0.5,1,2,4,8
set view 75, 31, 0.601098, 1.4385
set isosamples 60
# Removing unwanted stuff
unset xtics
unset ytics
unset ztics
unset key
splot e_estrela(x,y), e(x,y)
And the output I get (with the pngcairo terminal, but that's not relevant, I guess) is:
Is it possible to draw the contour base plane closer to the surfaces? And how about removing those vertical black lines?
For the first part, I tried playing wioth set zrange with no success. The base plane seems to be drawn a certain z-distance below the lowest z-range limit everytime.
Ideas? Thanks in advance!
To adjust the distance between your data and the xy-plane use the option
set xyplane relative <value>
where <value> gives you the distance between the xy-plane and the minimal z-value in relative fraction of the hight of your plot. So <value>=0 sets the distance to zero, <value>=0.5 to half the hight.
To control the border use set border where each border line is represented by bits. Please refers to the documentation for more details. In your case I would suggest:
set border 127+256+512 # or set border 1023-128
set grid #forces borders from xy-plane to plot
I'm trying to put two figures side by side using gnuplot with multiplot.
I want the resulting image to be rectangular so I use set size 2, 1. I also set the set multiplot layout 1, 2 option. However, the resulting image only uses the left part of the available space. Any help will be appreciated.
Thanks
Ahmet
Here is the resulting image
http://tinypic.com/r/33mlz04/6
And below is the gnuplot commands I'm using.
set terminal postscript eps color enhanced
set output 'figure.eps';
set size 2,1;
set multiplot layout 1, 2 ;
set title "Figure 1";
plot "data1.txt"
set title "Figure 1";
plot "data2.txt"
unset multiplot
Although I'm not very sure, with some trial and error I have solved it
set terminal postscript eps color enhanced
set output 'eps/image.eps';
set size 1,0.5;
set multiplot layout 1, 2 ;
set title "Figure 1";
set size 0.5,0.5;
plot "data/data1.txt"
set title "Figure 1";
set size 0.5,0.5;
plot "data/data2.txt"
unset multiplot
Try something like:
set terminal postscript eps color enhanced size 10,5
set output 'figure.eps';
set multiplot layout 1, 2 ;
set title "Figure 1";
plot "data1.txt"
set title "Figure 1";
plot "data2.txt"
unset multiplot
When you set the size on the terminal specification line, that determines the actual size of the plot canvas (in inches in this case). When you use set size on a separate line, that sets the size of the plot in relative units of the canvas size. This is different in older versions of gnuplot. For perhaps a better explanation, try help set size in gnuplot.
For even more control over the size/position of the plot, you can use set origin in conjuction with set size to change the placement and size of each plot. Finally, the most control can be achieved with set lmargin at <place> (and set rmargin ...) and so-on for tmargin and bmargin where the "lrtb" stand for left, right, top and bottom respectively.
So, to get a plot to fill all of the available space (left to right), you could:
set multiplot
set lmargin at 0
set rmargin at .5
plot sin(x)
set lmargin at .5
set rmargin at 1
plot cos(x)
unset multiplot
However, this is (usually) overkill. Usually gnuplot tries to make the margins big enough for your labels and such, but setting the margin explicitly disables that. I would suggest you go with the solution by andyras.
if you are having problems using this method for more than 2 figures add 'set origin 0,0' after 'set size 0.5,0.5'.
For example, for three figures :
set terminal postscript eps color enhanced
set output 'eps/image.eps';
set size 1.5,0.5;
set multiplot layout 1, 3 ;
set title "Figure 1";
set size 0.5,0.5;
set origin 0,0
plot "data/data1.txt"
set title "Figure 2";
set size 0.5,0.5;
set origin 0,0
plot "data/data3.txt"
set title "Figure 3";
set size 0.5,0.5;
set origin 0,0
plot "data/data3.txt"
unset multiplot