Commas in gnuplot labels - gnuplot

I'm plottng monetary data with gnuplot and currently I've managed to set the labels on the y axis to be floating point values with no decimals (rather than exponentials) but I want to be able to add comma's to the label but I cant figure out how.
Any ideas?
i.e. The current output gives me £25000000 - as you can see, the data isn't grouped - I want to split it in thousands so it appears as £25,000,000.
EDIT:
My current setting is
set format y '£%.0f'

As stated here the thousands separator depends on the locale-specific formatting.
If this setting allows for the thousands separator it will be printed with:
set decimal locale
set format y "%'g"
plot 1000*x
An other option would be to set the ytics manually (see here) like so:
set ytics ("5,000,000" 5000000, "10,000,000" 10000000, "15,000,000" 15000000, "20,000,000" 20000000, "25,000,000" 25000000)
plot[0:3] 10000000*x

Related

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: Replace decimal point by another character

Using gnuplot v4.6.6:
To increase the available space for the actual graph I want to reduce the space required by the y-axis label to the bare minimum.
I'm now using: set format y "%4.1s%c".
Which results in labels like 500.0k. It would be nice if I could reduce this by one more character resulting in labels that look like this : 500k0
However, I can't figure out how to get this. Can it be done, and if so: how?
Thanks for your help.
EDIT: Here's an example graph of what I have now:
For this graph I use set format y "%3.0s%c" which is okay most of the time. But in some cases an extra decimal would be helpful.
You can modify the decimal character:
set decimalsign 'k'
Update:
Or you could plot log10(bits/s);
set yrange[0:9]
set ytics 1
plot 'data.d' using 1:(log10($2))
That would represent everything between 0 bits/s and 10^9 bits/s with a single digit on the y axis...

Modifying labels in 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.

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.

Plot data with quarterly tic marks

I am plotting data that is recorded on the last day of the 3rd, 6th, 9th, and 12th months of the year. I would like the tic marks to be at 03/09, 06/09, ...
After reading the documentation, I thought this could be done by saying
set xtics "03/09", 7889220
because there are about 7889220 seconds in three months. But rather than starting with March, 2009, the tic marks start on the next day, shown here (with the remaining part of the plot removed):
Is there a way to force the tic marks to be at end of months?
UPDATED:
The date format in the input file is mm/dd/yyyy, which I am reading with these commands:
set xdata time
set timefmt "%m/%d/%Y"
and I'm then doing this:
set format x "%m/%y"
set xrange ["03/31/2009":"12/31/2010"]
Discussion:
The Gnuplot behaviour when you use set format x "%m/%y" will be to place xtics at month boundaries since that really is what this command is asking Gnuplot to do.
To solve your problem there may be two posisble approaches that you can take here depending on how large your data set is.
Approach1:
If you do have time stamps in your data file one possibility is to just use the xtics directly for plotting (suitable if you have a large dataset)
So you do away with all the time commands in your script and just use
plot 'Mydata.dat' u 2:xtic(1) w points
Approach2:
The other option is to set custom xtics, however you will have to do this by hand and if you have a large dataset this might be cumbersome (suitable if the dataset has tens of points)
set xtics ("03/09" "03/31/2009", "06/09" "06/30/2009", "09/09" "09/30/2009", "12/09" "12/31/2009")
Will give you tics at the exact days you need them to be.
Assumption:
I assume that the first column in your file are the time stamps and second column are the data values. Below, I show a graph where I use the manual setting approach (Approach 2).
Result with dummy data:

Resources