Gnuplot: Axis format - gnuplot

I have a question about the format of the axis in gnuplot.
I am obtaining a plot that looks like this
.
But I want the axis formats to match, I have so far used
"set format x '%.0t*10^{%.0S}'"
to obtain
.
The question is if there is any way of changing the * to a x so the y and x axis match. I have read that {/Symbol \264} should produce a x for me, but this does not seem to work on my system as it produces some other symbol.

Related

Plotting surface with gnuplot, but I only have a Z-data datafile

I have a data file containing z values (m x n = 2068 x 100), but I fail to find a way to make a surface plot in gnuplot out of that.
In MATLAB the command is straight forward: just surf(M).
The values correspond to readouts over time from a spectrometer, i.e.
wavelength scan1 scan2 scan3 scan4
772.7 3.9609 3.9623 3.9593 3.9643
772.8 2.4688 2.4749 2.4669 2.4689
772.9 2.7233 2.7250 2.7240 2.7270
I understand that gnuplot expects the data to be presented in x,y,z fashion, but my data does not provide that. I'm sorry that I can find no other way to describe what I'm after...
Essentially: the x values are in the first row, but the y values should be the index of the column if that makes sense.
Any help would be much appreciated.
Your data format is halfway between the two formats gnuplot knows about. splot $DATA matrix treats all values as z values (no x or y specified). splot $DATA matrix nonuniform expects the first column to contain y values and the first row to contain x values. You have one column of coordinate data but not one row of coordinate data.
It looks like your x values are evenly spaced, so it would produce a valid surface to ignore them:
splot 'matrix.dat' matrix skip 1 every 1::1
matrix tells gnuplot it is an array of z values
skip 1 tells it to skip the first row, which contains labels rather than z
every 1::1 tells it to read every column starting with column 1 (i.e. skip column 0)
However a much better approach is to draw a separate line for each scan rather than trying to treat it as a surface:
set ylabel "Scan" offset 5
set xlabel "Wavelength" offset 0,-2
set xtics .1 offset 0,-1
unset ytics
unset ztics
splot for [col=2:*] 'matrix.dat' using 1:(col):col title columnhead

How to use dgrid3d with X and Y points to plot an intensity map

I have a file with X Y data points (> 10^4)
12.399999999999999 3.7333333333333334
22.13333333333334 34.93333333333333
13.600000000000001 10.133333333333333
94.26666666666667 26.
25.333333333333336 8.666666666666666
52. 38.
25.33333333333333 51.733333333333334
24.799999999999997 37.333333333333336
77.33333333333333 5.466666666666667
13.2 7.733333333333333
33.46666666666667 4.666666666666667
33.86666666666666 46.
52.8 3.466666666666667
24.400000000000002 20.933333333333334
54.53333333333334 27.6
121.73333333333335 30.133333333333333
103.73333333333333 13.466666666666667
47.599999999999994 5.333333333333333
...........
(positive and non-gridded), which I would like to plot with Gnuplot.
I have been looking different posts and examples, and they provide a function for the intensity or directly the Z values corresponding to the intensity, or they use an array of values indicating pixels or squared zones of an image.
I would like to ask if there is a way to plot an intensity map plot providing only the X and Y points. Also, I would like to know if it is possible to indicate the range to plot and the granularity (the bin size or the interpolation order).
Thank you very much for the help
EDIT (based on Comments)
I have tried set size square
set autoscale fix
unset key
set view map
set xrange [0:200]
set yrange [0:200]
set dgrid3d 10,10,4
splot "data.dat" w pm3d
Gnuplot tells me that I need a third column with the weights.
I have no third column in my dataset, just the X and Y values.
How could I correctly use dgrid3d, and plot an intensity map or frequency map of my points?
Note: My Gnuplot is version 5.2, and there is an option bin which can be used to bin x values, but I do not know if it can bin 2D points too

Gnuplotting changing axis basis

i've got a data set that is of a vector f(x,y,z). Formatted as fx fy fz x y. This data set is of a crystal lattice and it's associated reciprocal lattice. The coordinates x y are in a non orthogonal basis. Such that x and y are unit vectors x=(1,0) y=(0.5,sqrt(3)/2). I'm trying to plot a set of 3 heatmaps one for each component of f. My issue is that I can seem to change the x and y axis such that they are the unit vectors above. Is there a way to make non-orthogonal/perpendicular axes in gnuplot? If not does anyone have any ideas on how to represent this data set?
Thanks in advance
What you can do is not change the axes, but apply a change of variable from your columns 4 and 5 to the cartesian coordinates x,y:
ex_x=1; ex_y=0
ey_x=0.5; ey_y=sqrt(3)/2
splot "file.dat" u (ex_x*$4+ey_x*$5):(ey_y*$4,ey_y*$5):1 with pm3d

Rotating a plot in gnuplot

1-How can I rotate my plot so y would be the new x axis and vice versa?
2- Change the maximum value of y axis from 60 to 100.
The plot is created by this script in the terminal :
set palette grey
plot 'color_map.dat' matrix with image
You can exchange the x and y axes with the using modifier. (Just like for ordinary plots, except that for matrix data, columns 1 and 2 are not in your data file, but are inferred.)
plot 'color_map.dat' matrix using 2:1:3 with image
If you actually just want to change the maximum value on the y (new x) axis, you would use set xrange[:100]. But it sounds like you might actually want to scale the data itself, in which case you could use
plot 'color_map.dat' matrix using ($2/60.*100):1:3 with image
Try help plot matrix for more details.

Plotting a series using gnuplot (Maclaurin series)

Is there a quick way to plot the Maclaurin/Taylor series using Gnuplot. For eg:
http://en.wikipedia.org/wiki/Power_series
I'm trying to plot each term of the series NOT the series f(x) vs x.
So, for sin(x) I'd like to plot on the x-axis, x, -x^3/3!, x^5/5! etc and the sum itself all on one axis without having to type each term in the sequence manually.
You can plot functions in gnuplot. In this case, you would have to define your series, for example:
gnuplot> a0 = 1
gnuplot> a1 = 0.5
gnuplot> a2 = 0.1
gnuplot> f(x) = a0 + a1*x**2 + a2*x**3
gnuplot> plot f(x)
This will give you:
Edit
Based on the comment to this answer, I'm proposing this (which should work for gnuplot 4.4 and higher):
First, define your factorial:
gnuplot> fac(n) = (n==0) ? 1 : n * fac(n-1)
Second, iterate over as many terms as you like (in this case 10). We're only interested in the uneven exponents, hence the upper bound is 20. Furthermore, every other "term" has to be multiplied by -1, thus two commands, and an increment of 4:
plot for [a=3:21:4] -1*x**a/fac(a), for [a=1:21:4] x**a/fac(a)
This will give you a plot like this:

Resources