Modifying labels in gnuplot - gnuplot

I am able to create the following boxplot using gnuplot.
However, I want the xtic labels to be of the form log(x).
For instance, label 2 would be written as log(100), 3 as log(1000) and so on.
Is there any way I can do this?

You must do that manually using set xtics (...):
set xtics ('log(1)' 0, 'log(10)' 1, 'log(100)' 2, 'log(100)' 3)
to have this automated a bit, you can loop over your x-values:
set xtics ('log(1)' 0)
set for [i=1:5] xtics add (sprintf("log(%d)", 10**i) i)
Something like
set xtics format "log(...)"
doesn't work. This uses the same syntax like gprintf, which allows to extract several information of the given tic values (like mantissa, power, scientific power, hex, octal, multiple of pi etc), but not to perform mathematical operations on the values (10**(ticvalue)) and use the result for the visualization.

Related

Set position of one tic number in 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.

Gnuplot overlapping ytics in multiplot

I'm trying to plot several graphs stacked vertically with no space between them using multiplot in gnuplot. My problem is that ytics of the different plots overlap. I know this can be avoided by defining a range for ytics, but I have to make 37 different multiplots with 4 stacked plots in each one so manually setting ranges is not an option.
So I was wondering if there was some way to force ytics not to overlap from within gnuplot of if the only option is to calculate and manually specify ytics range.
This is what I want to avoid
I thought of using GPVAL_DATA_Y_MAX an GPVAL_DATA_Y_MIN variables and use them changed by a factor of 20% to define the ytics range. This approach works, but I don't know how to round them so that they can adapt to different kinds of data, meaning that if they range from 0.3145 to 9.7601 they are rounded to 0 and 10 with 5 divisions but if the range goes from 0.3145 to 0.3150 they are rounded to 0.3145 to 0.3150 with 5 divisions)

Editing y axis range in Gnuplot

I have a plot with exponential y axis range. I'm using multiplot command by inserting two images in one row. So due to this wide y axis range I'm loosing some space which I could use it to show my plots in a better way. I want basically something like this
How could i do this? I think for doing this I have do some math operations in the y axis range. Also what is the most convenient command to insert ( xE-10) at top left of the plot.
reset
set terminal epslatex size 16cm,18cm color colortext
set output new.tex
set key off
set format $%g$
set title "sinx"
set ylabel "[kNm]"
plot 1000000*sin(x)
This is not my exact code but it looks similar to this. The plot I have presented is a part of the multiplot code and I use 7 input files with time series data of 300 seconds at a time step of 0.02. The point I want to edit the y axis range (use some mathtematical expressions) and also include the term ( xE-10 ) on the top of the plot something like this
You can manually add the exponent with a set label .... For instance, the following function takes large values within the given interval:
plot[0:50] exp(x)
We can place the "x 10^21" manually in the desired place after dividing the plotted quantity by it:
set label 1 "{/Symbol \264} 10^{21}" at graph 0,1.025 left
plot[0:50] exp(x)/1e21
You have to be careful with the exact placement of the exponent since it might lie outside the plotting area, in which case you should lower the top margin with set tmargin .... Also, to use the "times" symbol, you need to pass the enhanced option to your terminal. With the epslatex terminal, you can use latex syntax: $\times 10^{21}$.

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)

Resources