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.
Related
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.
I am trying to change my scale on gnuplot. I had a file from which I am plotting the fifth and sixth columns, and I am trying to change the x axis to a log scale. I am using
set logscale <2>
but it is saing that 'x' is an invalid axis. Is there a way to find out what the "name" of my 'x' axis is so that I can use this command?
From your question it's rather hard to see what you exactly want. Comment if this isn't what you're looking for. It sounds like you want to set the x axis to logscale base 2. It's done this way
set logscale x 2
In general, this is the command
set logscale <axes> <base>
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}$.
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.
I prepared a code to graph my script's csv output. They are column separated values.
I used code below to do that:
#!/usr/bin/gnuplot -persist
set datafile separator ":"
set terminal png nocrop font small size 640,480
set output 'mychart.png'
set style data histograms
set title "some graph title"
set xlabel "some x asis name"
set ylabel "some ya axis name"
plot "/home/username/Desktop/test.csv" using 2:xticlabels(1) notitle
This will draw the graph successfully. However I have two problems here. One in x axis, there are big numerical values such as 50000000, 6000000 so graph shows them in exponential format such as 5E+9 6E+8. But I would like to see full number. Second, in y axis, there are almost 20 alphanumeric values (some network parameter names) and each of them with at least 25-30 character. So they won't show up properly. Is there a way to write them with a smaller font and an angle?
Thanks
To change the format of the numbers shown on the y-axis, use e.g.
set format y '%.0f'
The labels of the xtics can be rotated (rotate by 45), aligned differently (right) and they can use a different font size (font), e.g.
set xtics right rotate by 45 font ',8'
See also rotating and justifying tics in gnuplot.
You may need to adjust the bottom border to have enough space for the labels, e.g. with
set bmargin 6
BTW: You should use the pngcairo terminal (available since version 4.4), which produced much nicer graphs than the png terminal.