How to plot on 2 different scales on an axis in gnuplot - 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.

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

how to read and understand seaborn using joinplot(f1,f2)

The following code
a= np.random.randn(100)
b=np.random.randn(100)
sns.jointplot(a,b)
produces
What is the histogram on the top and right hand side?
And how do I read this graph?
The histogram on the top shows the distribution of the variable at the x-axis and the histogram to the right shows the distribution of the variable at the y-axis.
And the scatter plot is the usual x=a Vs y=b. Hope it helps.
Dataser a's x axis also becomes x axis of the joint plot, database b's x axis becomes y axis of the joint plot. Graph on top and rhs, are same as the individual histogram. The graph is continuous, and changes on bin change, unlike histogram where it may be discontinuous

Gnuplot - Plot data on another abscissa by interpolation

Good evening,
I have a problem with Gnuplot. I tried to sum up my problem to make the comprehension easier.
What I have : 2 sets of data, the first one is my experimental data, about 20 points, the second one is my numerical data, about 300 points. But the two sets don't have the same abscissa.
What I want to have : I want my numerical data be interpolate on the x-experimental abscissa.
I know it is possible to do that with Xmgrace (paragraph Interpolation at http://plasma-gate.weizmann.ac.il/Xmgr/doc/trans.html#interp) but with Gnuplot ?
What I want to have in addition : is it possible, then, to subtract the y-experimental data of my y-numerical data at the x-experimental abscissa points ?
Thank you in advance for your answer,
zackalucard
You cannot interpolate the ordinate values of one set to the abscissa values of the other. gnuplot has no mechanism for that.
You can however plot both datasets using one of the smoothing algorithms (check "help smooth") with common abscissa values (which might (be made to) coincide with the original values of one set.)
set table "data1.tmp"
plot dataf1 smooth cspline
set xrange [GPVAL_x_min:GPVAL_X_max] # fix xrange settings
set table "data2.tmp"
plot dataf2 smooth cspline
unset table
Now you have the interpolated data in two temporary files, and only need to combine them into one:
system("paste data1.tmp data2.tmp > correlation.dat") # unixoid "paste" command
plot "correlation.dat" using 2:4
(If you have a sensible fit function for both datasets, the whole thing becomes much easier : plot dataf1 using (fit1($1)):(fit2($1)))
You can use smoothing, this should do the trick
plot "DATA" smooth csplines
(csplines is just one options, there others, e.g. bezier)
But I don't think you can automatically determine the intersection of the smoothed curved. You use the mouse to determine the intersection visually, or alternatively fit some functions f(x) and g(x) to your curves and solve f(x)=g(x) analytically

Inversed logarithmic scale in 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

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?

Resources