Set position of one tic number in gnuplot - gnuplot

I'm currently plotting a several plot one side to side. Since there are lots of graphs, I need to waste as little space as possible. At the moment I have this situation:
I want to "right align" the number associated to the first tic in the X axis and "left align" the number associated to the last tic in the X axis. In this way I can achieve the following (saving some pixels):
At the moment both tics and number are set automatically. Is there a way to achieve this in gnuplot? I know you can set via xtics left|center|right the alignment of all the values in the axis.
Regardless of my objective to achieve plot compactness (this may be a XY problem), the question still remains: but does exist a method to manually set the alignment of a particular tic?
Thanks for any kind reply
NOTE: I didn't wrie the version of gnuplot since using a particular version is not a requirement to solve the question.

not very clean solution, but you could for example first define the tics globally and then manually "override" the particular ticks "of interest":
set xr [0:100]
set yr [0:100]
unset key
set xtics 0,20,100
set xtics add (" 0" 0 0)
set xtics add ("100 " 100 0)
plot x w l lc rgb 'dark-red' lw 2
unfortunately, it seems that doing something like this:
set xtics 0,20,100
set xtics add right ("100" 100 0)
affects the alignment of all ticks and not just the added one...

What bugs me in changing the position of only the first and last tic marks is that the space between the labels 20 to 30 won't be the same as 30 to 40 and so on. I've had this problem in the past, and you can play with the number of tics and the range. For example:
set xtics 10
set xrange[15:105]
or if you really want to stick to the 20:100 range:
set xtics 15
set xrange[20:100]
You can also add mxtics to make it look even prettier. This is not a formal solution by any means, just a nice workaround. Hope it helps.

Related

Manual scaling of axis (poltting with boxes) in gnuplot

I'm trying to plot a really long list, which represents frequency of some data. The x axis goes from 1 to 1881, and the y goes from 1 to 1978. I tried plotting with the following configurations:
set log y 5
set log x 32
set xtics 2
set ytics 5
plot "freq.dat" w boxes
But i get the following result:
Which is clearly not good because there are these intersections of the boxes. I want to have some kind of scale that have a lot more space between 10 and 150 than the outside of this area. How can i do that? I've tried every combination of logs and xtics and couldn't make it look good. The y axis seems good to me, the only problem is the spacing of x-axis.
Also, i want to know how to do this in gnuplot specifically (if possible).
Thanks.
It seems to me that your script overrides somewhere the default boxwidth. The default behavior is:
By default, adjacent boxes are extended in width until they touch
each other. A different default width may be specified using the set boxwidth command. Relative widths are interpreted as being a
fraction of this default width.
So for example this:
set terminal pngcairo enhanced
set output 'fig.png'
set log x 2
set log y 5
set yr [0.2:3125]
set xr [1:512]
set boxwidth 1 relative
set xtics 1,2,512 out nomirror
set ytics 1,5,3125 out nomirror
unset key
#set style fill pattern 6
plot 'freq.dat' w boxes lc rgb 'royalblue' lw 1.1
then yields:

GNUPlot: Display less marks on x-axis?

I'm trying to get less marks on the x axis to display, since it's not exactly readable as to what size those values are.
Right now I'm using the
set xrange [1000:1000000]
directive.
You can use the command
`set xtics 5e5`
(or some other number) to space the tics further apart. For your data it looks like three tics are fine, you could even get away with two:
`set xtics 1e6`
Sadly gnuplot lacks an option to set the number of tics explicitly.

gnuplot - changing the tics in pm3d map

Well, I am trying to plot a matrix-like data file using pm3d option as follows
set pm3d map
set pm3d interpolate 0,0
splot namefile matrix
I have tried to upload an image but it seems I don't have enough reputation. Ok, so the problem is that the data come from logarithmic binned x and y axes, but the default option for the tics separation is the lineal one (1, 2, 3, ... ). If I want to rescale the tics to another interval, it is easy as long as I keep this linearity ( e.g: 0, 10, 20,... ). However I would like to rescale them to my data interval but logarithmically separated (1, 10, 100,... ). Of course, what I only want to change are the tics, whereas the proportion within the plot is kept the same.
After thinking and looking around I could not find a satisfactory answer. Any hint on how to solve it ?
Thank you !
If you only want to change the tics, but not the scaling of the data you must manually set the tics like
set for [i=1:5] xtics add (sprintf('%.0f', 10**(i-1)) i)
set for [i=1:5] ytics add (sprintf('%.0f', 10**(i-1)) i)

adding space between x axis and xtics in gnuplot histogram

Currently I created graphs with small size. The spacing really important at this case. I want to add more vertical space between my xticlabels and x axis.
I have tried to set the x bar with
set xtics offset 0,graph 0.05
my gnuplot output:
The data and gnuplot script still same with my previous question here.
You can do the following:
First add a little bit of bmargin by
set bmargin 3
Since you need to add vertical space between your xticlabels and x-axis, you need to adjust the Y-offset, which can be done by the following
set xtics offset 0,-1,0
You can play around with the values to suite your need.

Creating a microphone polar pattern plot in gnuplot

I would like to create a microphone polar pattern plot that has a scale of -20 (in the center) out to +5 in steps of 5. I have found similar code but nothing that allows for the scales to be negative.
Multiple patterns will then need to added to the plot covering a few different frequencies, I have degree values (0-360) and corresponding dB values (-25 - +5).
This is what the plot should look like (though with slightly different scales):
The closest gnuplot I have found to this is here: How to get a radial(polar) plot using gnu plot?
Perhaps this could be modified to suit my needs?
I would also like 0 degrees to be found at the top of the plot rather than on the right.
I am new to using gnuplot so I am not particularly familiar with its code, therefore it has been difficult for me to modify the code with any great success (so far anyway).
So you want to plot a polar function, e.g. r(theta) = 1 + sin(theta).
Plotting the function is quite easy, just do
set polar
plot 1+sin(t)
A simple polar grid can be plotted with
set grid polar
but that has the raxis and the rtics on a different position than where you wanted. It is not problem to specify custom labels. But angular labels aren't supported, so you need to set them manually. And the border and the other axes and tics must be unset.
To get the very same image as you showed, use the following script:
set terminal pngcairo size 700,600 font ',10'
set output 'cardioid.png'
set angle degree
set polar
set size ratio 1
set tmargin 3
set bmargin 3
set style line 11 lc rgb 'gray80' lt -1
set grid polar ls 11
unset border
unset xtics
unset ytics
r=1
set rrange [0:r]
set rtics 0.166 format '' scale 0
set label '0°' center at first 0, first r*1.05
set label '180°' center at first 0, first -r*1.05
set label '90°' right at first -r*1.05, 0
set label '270°' left at first r*1.05, 0
set for [i=1:5] label at first r*0.02, first r*((i/6.0) + 0.03) sprintf("%d dB", -30+(i*5))
unset raxis
plot 0.5*(1+sin(t)) linewidth 2 t ''
With the result:
That includes some offsets for the labels, which depend on the terminal, the canvas size and the font size. So you may need to adapt them.
I had to increase the top and bottom margins a bit (here by 3 character heights) in order to have enough space for the angular labels. They aren't included in the automatic margin calculations, because the don't belong to an axis.
Unfortunately Christoph's answer is wrong.
You can see that if you check where the plot curve crosses the 5db circle.
What should be plotted is
20*log10(A+B*cos(t))
where A+B = 1 and A - B determines the (nominal) directivity pattern.
The first diagram seems to be for A=B=0.5 which makes for a cardioid pattern.

Resources