Inversed logarithmic scale in gnuplot - gnuplot

When plotting data which are very dense in small ranges of y, the logarithmic scale of gnuplot is the right scale to use.
But what scale to use when the opposite is the case? let's say most y values of different curves are between 90 and 100. In this case I want to use something like a inversed logarithmic scale. I tried a log scale between 0 and 1 but gnuplot wants me to choose a scale greater than 1
How can I achieve this?

You are right, you can use the inverse of the logarithmic function, which is the exponential. But gnuplot only supports logarithmic scales, so you have to do the conversion on your own:
plot "myData" using 1:(exp($2))
You will also have to handle the axis tics on your own. Either you just set them via a list like
set ytics ("0" 1.00, "1" 2.72, "2" 7.39, "3" 20.09, "4" 54.60, "5" 148.41)
or you use the link feature for axes of gnuplot 5. The following code uses the y2axis (right y-axis) to plot the data and calculates the tics on the left y-axis from the right one.
set link y via log(x) inverse exp(x)
plot "myData" using 1:(exp($2)) axes x1y2
Side note: Always remember that a non-linear axis is hard to understand. Logarithmic scales are common, but everything else not. So, be careful when presenting the data

Related

What the 'set logscale' does in gnuplot?

My question is more about math then the actual code.
When use the command
set logscale
on gnuplot 5.0 what is happening ?
It should represents the logarithmic values values of the x and y points.
But it doesn not seems to work properly. For example on my data I have x and y values smaller then 1 so I am expecting to see negative values for these values on the plot, but I see only postivie values.
What I am doing wrong ?
The logarithmic scale still shows the real values around the axes, just their distances are logarithmic. To really see the negative values, you need to really apply the log function:
plot "file.dat" using (log($1)):(log($2)) with lines
without setting the logscale.
A specific example might help to illustrate the effect of logarithmic scaling:
set xrange [0.1:10]
plot x**2
Let's plot this again, but this time on a logarithmic scale. Watch how the scaling of the x and y axes changes:
set logscale
replot

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.

Gnuplot: nonlinear scaling for y axis

I have 2 datasets which I want to plot on top of each other. The first data set has a yrange of [-10:10], while the second has a range of [-2:2]. If I just plot them on top of each other in the usual linear scale, it is very difficult to see any features of the second data set:
Ideally I would like a nonlinear scale on the y axis to really emphasise what is going on between -2 and 2. I would like to design a y axis which looks like this:
So that most of the middle part of the plot is between -2 and 2. (I just manually added ytics in this figure) Does anyone know how to accomplish this via the "set link" command or something similar?

gnuplot: Plot boxes next to each other of discrete function

How can I plot discrete functions, like the Poisson distribution, in gnuplot with different parameters in the same plot without having them overlap?
For example: I plot the Poisson distribution with lambda = {1,3,5} and with boxes in the same plot. To discretize I do set xrange [1:15]; set sample 15 so that it only plots the discrete values. This works pretty well. The only problem is, that the boxes of the three different Poisson distributions (of the three different lambdas) overlap (because they all have a value at x=1, x=2, etc). Making them transparent looks still ugly (color mixing on overlaps). So I want the function to be displayed shifted. The values of Poisson(x, lambda=1) and Poisson(x, lambda=3) and Poisson(x, lambda=5) should be calculated for x at x, but for each lambda should be displayed slightly more shifted to x than the previous lambda plot so that the all boxes don't overlap and can clearly be seen.
I hope I expressed this clear enough.
With datafiles it's easy (just add something with using $1+0.1:2, e.g.) but how do I shift analytical functions?
In order to plot analytical functions with special needs, which require the using statement, one can use the pseudo filename +. In your case, the plotting script might look as follows:
set xrange[-0.5:15.5]
set samples 16
set style data boxes
set boxwidth 0.2 absolute
set style fill solid noborder
poisson(x) = lambda**x/int(x)!*exp(-lambda)
plot for [lambda=1:5:2] '+' using ($0-(lambda-3)*0.1):(poisson($0)) title sprintf("λ = %d", lambda)

How to plot on 2 different scales on an axis in gnuplot

I want to plot some data on x axis range [0:1] and y axis range [0:100], but on the x axis I have most of my data in range [0:0.1] and less data in the rest of the range. I thus wanted to expand the [0:0.1] range. I cannot use a logarithmic scale for the x axis as I have some data which is 0 and I cannot plot it if I use a logarithmic scale. Is there a way for plotting this in Gnuplot?
Ideally I would want to apply a logarithmic scale to the x axis, but start my plot from 0. That would help me to cover all the data and highlight the [0:0.1] range as well. Can it be done?
As you noted, it is impossible to have a logarithmic scale with a 0. I would use two graphs side by side, with separate x axes. You can do this through set multiplot layout 1,2.
I agree with Svante. An other option would be to introduce a second x-axis in the same plot. Then one x-axis would scale from 0:0.1 and the other would scale from 0:1. Depending on your data however this approach could be very confusing but I think especially if your data is primarily located between 0:0.1 this could work.

Resources