gnuplot: Replace decimal point by another character - gnuplot

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...

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: Polar plot showing variable ranges

I've got a dataset of angle ranges that I'd like to represent as a polar plot.
The format is as follows:
[Radius]\t[Range 1 lower] [Range 1 upper]\t[Range 2 lower] [Range 2 upper]...
A typical data line looks like this:
1.181 0 0 31.8196 38.3883 141.612 148.18 180 180 211.82 218.388 321.612 328.18
The number of ranges per line can differ, there are also lines without any ranges. Ideally I'd like to end up with a polar plot, where at a given radius the angle between the lower and upper limit of each range is filled, while the rest of the plot is empty.
The ranges do not overlap, but some of them have the same angle as lower and upper limit (for instance the "0 0" range in the example above), what should still be visible, as (as always) those single point and hardly-visible details in the calculation turned out to be those observed in experiment...
For now I've changed the C-program that outputs said ranges to give me a cloud of points with polar coordinates which I plot with dots, but I'd really prefer a kind-of vectorial plot with filled areas, as that'd mean (much) lower file size, and would allow zooming...
Any help would be appreciated, thanks in advance, Andreas
There are purely gnuplot 4.4+ solutions, but they will be intricate. One reason is that polar plotting of data files is not done with polar interpolation, but linear interpolation (straight lines between the endpoints). I would rather have the C program output the gnuplot commands to plot your data directly, e.g.
set polar
set angles degrees
plot (t<38.3883&t>31.8196)?1.181:1/0 with filledcurves above r=0, \
(t<...
I'd advise to treat the 0-range cases separately with set arrow from 0,0 to r*cos(angle),r*sin(angle).
I'm not sure the file will be so much smaller, again gnuplot will generate a polyline to approximate the arc of circle at r=1.181. If you want a small file with actual arcs of circle, you may want to generate svg code directly from your C code.

Excel chart: on/off values with timestamp

I have 3 columns of data, eg:
http://i.stack.imgur.com/XjGmu.jpg
When Excel creates a line graph of this, the blue line is what i get.
This is not correct because the time stamp shows the time when something is switched on (255) or off (0) (could also be the current state eg 16:08). So I'd like a graph like this - see the red line (with a time-based X axis off course):
http://i.stack.imgur.com/vNvPk.jpg
Anyone can help? Thanks
As #Jon49 indicated, you need to plot additional data points--two y values for each x value: one to plot the point at y=255 and one to plot y=0.
If the time-span of the data is at least a few days, you can use a line chart. But in your case since the values are within a day, the scatter chart with straight lines is the only option due to the limitations of the scale units for line charts.
The key is the values need to be in the correct order. Each y=255 value needs to be followed by the next time-stamp's 255 value followed by it's 0 value, followed by the next time-stamp's 0 value:
Excel doesn't support this type of discrete value graph (at least not excel 2k3 that I am using); your best bet is to use a bar graph and then go into the settings and set the gap width down to zero.
Not sure what the best way is but I would automate what I describe below on how to do (unless this is a one time deal, then just brute force it):
Separate the 255s from the 0s. Make sure for every 0 time there is a corresponding 255 time. Take the zero times and put in a scatter plot then add a y-error bar and make the fixed value equal to 255. Format to how you like it.
Now for the 255s. Add those to the chart by pairs. Make the chart type for these pairs scatter plot with a line. Format how you would like them to look.
Let me know if that doesn't make sense to you.

Commas in gnuplot labels

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

gnuplot: display only the roots

Gnuplot, a great package ... I'm in love with it. But we can have our tiffs as well, as any couple :-)
This time, I wanted to simply plot the roots of an equation: say a quadratic to keep things simple. However, I only want two nice round dots appearing on the x-axis representing the point where the quadratic crosses the x-axis or y=0 axis. In other words the roots (when they are real that is).
I don't want to do this with datafile ... I want gnuplot to calculate the roots and plot them.
First off, my attempts: single points aren't really what gnuplot would have you plot, it likes a good wide range of values. Preferably filling up the whole width of your canvas.
It's possible to locate a rectangle at a certain coordinate on your plot, but I wanted a round point. Currently I'm chasing up how to do a tiny filled polygon at that point. I have tried the "samples" option bu it doesn't seem useful.
Also though about defining a dirac-delta function so that only one point would be highlighted (though two would be needed).
ANy suggestions welcome, thanks.
there is a way, but it takes just a little bit of fiddling
narrowness=1
set yrange [0:10]
set xrange [-10:10]
poly(x)=(x**2+3*x-2)
roots(x) =floor(narrowness*poly(x))?1/0:0
plot roots(x) w points pt 7
depending on the function and the range you will need to set the width differently. if you see too many circles increase the narrowness, if you see too few (aka. none) decrease the narrowness
Cheers!
/B2S
oh, and PS. to increase accuracy set samples to some higher value
And Alternatively if you happen to already know the roots, say r1(2,0) and r2(-1,0) then you can plot them using
plot '-' with points pt 7
2 0
-1 0
e
Not sure if this really helps, but if you can define a custom function to calculate the roots, gnuplot will display it.

Resources