I am trying to plot a graph with increased font size in gnuplot. A typical example is:
p sin(x) w l lw 5
set border lw 4
set tics font "Halvetica Bold,20"
So, I am trying to have:
adjust plot size without changing the canvas size to accommodate x/y label and tics
to adjust space between tics and label
How can I achieve this?
Kindly help.
The margins and the label positions depend on the total font size. You can specify this as part of the set terminal command.
The following script gives good margins and label positions:
set terminal wxt font ",20"
set border lw 4
plot sin(x) lw 5
For your example, you could adjust the margins with set lmargin ... and similar commands, and adjust the tic offset with set xtics offset ...:
set terminal wxt
set border lw 4
set tics font "Halvetica Bold,20"
set bmargin 3
set lmargin 10
set xtic offset 0,-1
set ytics offset -0.5,0
plot sin(x) lw 5
Related
I am trying to make a wedge-shaped plot in polar coordinates spanning from 0 to 60 degrees. Something like the following figure: Wedge-plot I want
However, the command "trange" is used for the range of the plot, not of the grid itself, and I always end up with the full-circle grid, like this: Same plot but with full grid.
Is there a simple command to set the limits in the angle variable? Here is the code I used to plot the former figure in gnuplot 5.2
set terminal pngcairo enhanced font "arial,10" fontscale 1.0 size 600, 400
set output 'polar1.png'
unset key
set border 4096 lt black linewidth 1.000 dashtype solid
unset xtics
unset ytics
set size ratio 1 1,1
set raxis
set ttics 0.00000,30 font ":Italic"
set polar
set grid polar 30.0000 lw 1.5
plot cos(4*t) lt 3 lw 2
Thank you in advance!
I guess there is no "intended" way to limit the maximum angle in a polar plot.
So, there is a simpler (but ugly) workaround, which simply covers the unwanted part by a filled polygon.
Note: There will be an issue if your rmax is not an integer multiple of rtic 0.2, i.e. a plot with rmax=1.05 will not look as desired. Therefore, as a workaround an extra rtic at rmax is added.
Script:
### plot only part of polar plot
reset session
rmax = 1.05
amax = 60
set polar
set rrange [0:rmax]
set rtics 0.2 scale 0.5
set rtics add ('' rmax)
set grid r polar 10 lt black lw .3
set trange [0:2*pi]
set ttics 0,10 format "%g°" font ":Italic" scale 0.5,0.25 offset -1,0
set mttics 2
set xlabel "r-label"
set xrange [0:rmax]
unset xtics
set yrange [0:rmax]
unset ytics
set size square
set border 4096
set lmargin 0
set tmargin 0
unset title
unset key
set samples 300
set obj 1 polygon from graph 0,0 to first rmax*cos(pi/180*amax),rmax*sin(pi/180*amax) \
to first rmax*cos(pi/180*amax), screen 1.0 \
to first 0, screen 1 to screen 0,1 to screen 0,0 to graph 0,0 \
fc rgb 0xffffff fs solid 1.0 front
set arrow 1 from graph 0,0 to first rmax*cos(pi/180*amax),rmax*sin(pi/180*amax) lc "black" nohead front
plot cos(4*t) lt 3 lw 2
### end of script
Result:
I am trying to plot an inlet graph which is shown in Figure. Being an inlet graph it is needed to show x tics and y ticks of relatively big sizes for clear visibility. But when I increase the fonts as,
set xtics font ", 40"
tics overlaps with axis. I increased the plot size set term png size 1000, 1000 but still the issue persists. Kindly suggest if there is a way to move the tics below or to a desired position in graph.
Edit:
The gnuplot script looks like this,
set term png size 1000, 1000
set output "b_vs_N.png"
set style fill solid
set style circle radius 0.001
FIT_LIMIT=1.e-14
set yrange [0.15:0.25]
set style fill solid
set style circle radius 0.001
set xtics 10
set ytics 0.03
set border 15 back lw 6
set xtics font ", 40"
set ytics font ", 22"
set ylabel "b" enhanced font "1 {,40}"
set xlabel "N_i" font "1 {,40}"
set lmargin 12
set bmargin 4
set palette model HSV
set palette rgb 3,2,2
set palette maxcolors 12
set view map
AA(x)=a+b*x+c*x**2
fit AA(x) "data.txt" using 1:2 via c, b, a
plot "data.txt" using 1:2 lt 1 pt 11 ps 2.0 lc rgb "black" notitle, AA(x) w lines lw 2 lc rgb "sienna1" notitle
Your example is uncomplete without code and therefore difficult to reproduce. Please check help xtics. There is the option offset.
Maybe the following example helps to solve your issue.
In the example below no special offset seems to be necessary, i.e. offset 0,0, but you can shift and adjust the labels in x and y direction.
Code:
### tic label offset
reset session
set multiplot
plot sin(x)/x
set origin 0.07, 0.6
set size 0.3,0.3
set xrange [0:10]
set xtics 5 out font ",20" offset 0,0
plot x**2
unset multiplot
### end of code
Result:
In gnuplot, we can set the tick scale, but this only affects the length of the ticks.
How can we change the width of the ticks?
I don't see any option in the tags of xtics or ytics that would set the appropriate width.
As theozh says, the tics are drawn using the 'border' line type. If necessary I suppose you could turn off the border, set the border linetype to whatever you want the tics to be, and then use a graph-sized rectangle to replace the border.
set border lc "black" lw 0.25 # thin lines for the tics
set border 0 # don't draw the normal border
set tics scale 3.0 # longer than usual tics
set obj 1 rectangle from graph 0,0 to graph 1,1
set obj 1 lc "black" lw 2.5 # heavy line for the "border"
set obj 1 fillstyle empty
set grid x y
plot sinc(x)
Check help border. My guess would be that the tic width can probably not set independently of the border. Well, you could play with multiple graphs with different borders and tics on top of each other. Check help multiplot.
Code:
### set tic width
reset session
set border lw 3
set xtics scale 4
set ytics scale 1
plot x
### end of code
Result:
I am trying to use gnuplot to draw a figure. Due to the limited space, the figure is drawn like this:
I am thinking to move the first three labels (ins-replace, bb-split and func-reorder to the top of the figure, outside!)
So it should be something like this :
set key outside
But basically how to select the first three keys and move them to the outside? Is it possible to do so?
I put my script here:
set term pdf size 10,8 font "Arial,44"
set output "plot/bzip-ropbase-mix.pdf"
set size ratio 0.6
#set multiplot layout 1,1
set datafile separator ","
set offset 0, 0, 0, 0
set xtics norangelimit
set ytics nomirror
set termoption dashed
set ylabel "Gagdet Elimination Rate (%)"
set xlabel "Iteration"
set key bottom right
set yrange [0:110]
set style data linespoints
set key vertical maxrows 5
plot 'plot/bzip-ropbase-data.csv' using 11:xtic((int($0)%4)==0? sprintf("%d", $0*50):"") title columnheader(11) pt 4 lw 1, \
'' using 12 title columnheader(12) pt 5 lw 4 ps .8 lc rgb "#4169E1", \
'' using 13 title columnheader(13) pt 6 lw 4 ps .8 lc rgb "#DAA520", \
'' using 14 title columnheader(14) pt 7 lw 4 ps .8 lc rgb "#FF7F50", \
'' using 15 title columnheader(15) pt 8 lw 4 ps .8 lc 7
Could anyone give me some help? Thank you!
You cannot do this automatically but there are ways around it. The first one to come to mind is to use multiplot, then plot first all the functions and files whose title you want outside and then all of those that you want inside. You'll need to disable drawing borders etc. for the first instance and then enable it for the second instance. To make sure your plotting area remains constant during the two plot instances you'll need to hard set the margins:
set multiplot
set xrange [0:2.*pi]
# Set the margins
set lmargin at screen 0.1; set rmargin at screen 0.98
set tmargin at screen 0.8; set bmargin at screen 0.1
# Disable drawing borders and tics
unset border; unset tics
# Set position of the legend
set key tmargin
# Draw the first batch of stuff
plot cos(x) lc 1
# Enable drawing borders and tics
set border; set tics
# Set position of the legend
set key inside
# Draw the second batch of stuff
plot sin(x) lc 2
I have been trying very unsuccessfully to stack 3 graphs together in a multi-plot layout on a canvas that is a ratio of 2:3(width by height).
set terminal postscript eps enhanced "Helvetica" 24 color
set output "data.eps"
set timefmt "%s"
#set size 1.0,1.5
#set bmargin 2
#set tmargin 2
set size 1.0,1.5
set multiplot layout 3,1
set size 1.0,0.5
set tmargin 2
set bmargin 0
set ylabel 'Distance'
set format x ""
set ytics nomirror font "Helvetica,10"
set key top
plot "trace1.dat" using 1:3 axes x1y1 title "distances" with lines lw 2 lc rgb 'blue'
set size 1.0,0.5
set bmargin 0
set tmargin 0
set ylabel 'Power (W)'
set format x ""
set ytics nomirror font "Helvetica,10"
set key top
plot "trace2.dat" using 1:2 axes x1y1 title "device" with lines lw 2 lc rgb 'red'
set size 1.0,0.5
set bmargin
set tmargin 0
set xdata time
set ylabel 'Power (W)'
set xlabel 'Time (EST)' offset 0,-2.8 font "Helvetica,32
set format x "%b %d, %H:%M"
set ytics nomirror font "Helvetica,10"
set xtics nomirror rotate by 90 offset 0,-2.0 out font "Helvetica,10"
set key top
plot "trace3.dat" using 1:2 axes x1y1 title "aggr" with lines lw 2 lc rgb 'blue'
unset multiplot
When I do something like above, I get the plot shown below, there's a lot of blank space at the top of the canvas and the 3 multiplot graphs seem to overlap each other.
Any kind of help or pointer will be greatly appreciated.
In order to use a bigger canvas, you must use the size option when setting the terminal, e.g.:
set terminal postscript eps enhanced size 10cm,15cm
set size just changes the plot size relative to your canvas. To see this, consider
set terminal wxt
set size 1.0,1.5
plot sin(x)
Parts of the plot disappear, because it is much too high with respect to the canvas.
To stack three plots with same heights, in my opinion its best to use fixed margins:
set terminal pngcairo size 600, 900
set output 'stacking.png'
set lmargin at screen 0.15
set rmargin at screen 0.95
TOP=0.98
DY = 0.29
set multiplot
set offset 0,0,graph 0.05, graph 0.05
set xlabel 'time'
set ylabel 'ylabel 1' offset 1
set tmargin at screen TOP-2*DY
set bmargin at screen TOP-3*DY
set ytics -1000,500,1000
plot 1150*cos(x) title 'First'
set xtics format ''
unset xlabel
set ylabel 'ylabel 2' offset 0
set tmargin at screen TOP-DY
set bmargin at screen TOP-2*DY
set ytics -100,50,100
plot 101*sin(x) title 'Second'
set ylabel 'ylabel 3' offset -1
set tmargin at screen TOP
set bmargin at screen TOP-DY
set ytics -8,4,8
plot 10*sin(2*x) title 'Third'
unset multiplot; set output
The result is (with 4.6.3):
In order to avoid overlapping labels of the ytics, you must change the range where the tics are drawn, e.g. with set ytics -100,50,100, which puts ytics between -100 and 100 in steps of 50. Using set ytics rangelimited doesn't work
To increase the distance between the plot curve and the border, use set offset with graph coordinates, like done in the above script.
I started with the lowest plot, because only that has x labels and an xlabel.
You need to use set origin, too.
set terminal postscript eps enhanced
set output "data.eps"
set size 1.0,1.5
set multiplot layout 3,1
set size 1.0,0.5
set origin 0,1
...
plot ...
set size 1.0,0.5
set origin 0,0.5
...
plot ...
set size 1.0,0.5
set origin 0,0
...
plot ...
unset multiplot