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:
Related
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:
I would like to create a color bar plot of a single variable that draws a box to the left in red if the variable is negative and green to the right if positive.
I am failing to get rid of the y axis completely. There shall be no marking of it whatsoever. Second the x-axis and tics is hidden behind the box. I need it visible. Third the plot of the line at 0 is really unnecessary as I have already drawn all I need but gnuplot wants a plot cmd with some sort of argument. I tried plot 0 lt bgnd but that left an ugly white line in my box. I guess I can live with that. Arrows at the ends of the x-axis would be nice, too.
This is the current state of the code. (the variable v will later come from the outside world as command line argument)
v= 7.3
if (v<0){boxcolor= 'red'}
if (v>=0){boxcolor= 'green'}
unset border
unset ytics
unset key
set yzeroaxis
set xzeroaxis
set xtics axis
unset ytics
set xrange [-10:10]
set object 1 rect from 0.0,-0.5 to v,0.5 back fillcolor rgb boxcolor
plot 0
Result currently:
You are probably looking for something like this:
Update: improved version
using graph and first coordinates for the arrow (check help coordinates), hence independent of the actual x-range.
using xzeroaxis (check help xzeroaxis)
Script:
### only x-axis with arrows
reset session
set border 0
unset ytics
v= 7.3
boxcolor = (v<0) ? 'red' : 'green'
set xrange [-10:10]
set xtics axis mirror
set xzeroaxis lt 1 lc "black"
set object 1 rect from 0.0,-0.5 to v,0.5 behind fillcolor rgb boxcolor
set arrow 1 from graph -0.03, first 0 to graph 1.03, first 0 heads filled
plot cos(x)
### end of script
Result:
Another answer: This one uses the built-in axis variants rather than an arrow:
set border 0
unset key
# In newer gnuplot versions there is a keyword "nodraw"
# Here we define a synonym that works with older versions also
hide = -4
set yzeroaxis lt hide lc hide
set xzeroaxis lt black
set tics front
unset ytics
set xtics axis
# define rectangle here
set object 1 rect from 0,-.5 to 5,.5 behind fs noborder fc "green"
#
plot 0 with lines lc "black"
gnuplot adds grid lines even on axes, it can cause unpleasant effects:
set logscale x
set xrange [0.01:100]
set xtics font ",12"
set x2tics font ",12"
set mxtics 10
set ytics font ",12"
set y2tics font ",12"
set grid xtics mxtics ytics lt 0 lw 3, lt 0 lw 0.5 behind
set grid
plot sin(x)
Especially if one then plots the above to eps, it looks like there are both logarithmically spaced and linearly spaced tics on the x-axis. Is there any nice way to get rid of the grid lines at axes? A workaround would be to make the axes thicker, but that is not the way I want. I really want to delete those grid lines.
To explain what I mean
The linearly spaced tics that are seen in the picture are actually the dotted grid, so it has nothing to do with tics...
As shown, there are both log and linear tics along x. That is because both the x axis and the x2 axis are contributing tics to both the top and bottom borders. You can turn that off with
set tics nomirror
Are you asking how to make the range of the tics smaller than the range of the axes? In the plot you show, that would be
set yrange [-1:1]
set ytics -0.8, 0.2, 0.8
set ytics add (-1 2, 1, 2)
The last command adds back explicit tics at y=-1 and y=1 without generating a corresponding grid line. See documentation for set xtics list
I'm using gnuplot to generate some plots with an x axis ranging from 0 to 20. Is it possible to set the color of some tics or axis numbers to a different color from the standard black?
I only found a way to change the color of the all the numbers in the x axis red with set xtics textcolor rgb "red".
What I need is to be able to change the color of the tic or number at x=0,3,6,... to red and all the others should stay black. Is this possible with gnuplot?
The color of the tic marks is set by the border color, so one can do something like this:
reset
set multiplot
set xrange [-5:5]
set xtics -5,1,0 # these tic marks will show up in black (the default border color)
set yrange [] writeback # save auto-generated y range for later
plot sin(x)
set border 0 linecolor "red" # change border color, and turn off drawing of the border
set xtics 1,1,5 textcolor "blue" # these tic marks will show up in the new border color, and we can specify the color of the labels
unset ytics # we don't want to display the y tics again
set yrange restore # use same range for y axis as before
unset key
plot NaN
unset multiplot
This solution also uses multiplot, but uses the second plot only to draw tic marks and labels whose color is different from the default black. It is important that the two plots have the same ranges and margins.
This might be cheating a bit, just create the plot twice with different xtics command on top of each other:
set xrange [0:10]
set multiplot
set size 1,1
set origin 0,0
set xtics 1 textcolor rgbcolor "green"
plot sin(x)
set size 1,1
set origin 0,0
set xtics 1, 2 textcolor rgbcolor "red"
plot sin(x)
unset multiplot
seems to work for me (gnuplot: Version 5.2 patchlevel 2 last modified 2017-11-15)
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