Rotating a plot in gnuplot - 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.

Related

Gnuplot: Linear scaling data from a column to a specific range

I am making a circle chart using gnuplot. The first two columns plot a point on the XY plane, and I want the third to dictate the size of the circle. The third column has data between 1000-5000, so I have been using:
plot 'foo.csv' u 1:2:($3/100) w circles
which works ok, but I am wondering if there is a better way.
I made the same chart using d3.js, where I used the scaleLinear() function to map the data from column three (the domain, 0-max value) to the range (1-10). Is there anything similar in gnuplot, where I can map my data to a specific range like this?
The "stats" command can the information required for scaling.
If you want to scale input range [0:max] to effective [0:10] this would do the trick:
stats 'foo.csv' using 3 nooutput
plot 'foo.csv' using 1:2:($3 * 10./STATS_max) w circles
If the linear range does not necessarily start at zero then it may be worth defining a scaling function first.
stats 'foo.csv' using 3 nooutput
scale(y) = 10. * (y - STATS_min) / (STATS_max - STATS_min)
plot 'foo.csv' using 1:2:(scale($3)) with circles

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

Gnuplot transform x axis data with in the plot

I have data in this format
apple 1
bananna 3
ornage 5
fig 4
I want the x axis data to appear in the plot and not in the axis as such. Moreover they are words and not numbers.
How can I do it please?
The question is a bit unclear. Where do you want the labels to show up? Here's an example where I'll put the label "apple" at the point (0,1) and the label "banana" at the point (1,3), etc. (each label is moved 1 unit further down the x axis):
plot 'data.dat' using (column(0)):2:1 with labels
You can also put points associated with it:
plot 'data.dat' using (column(0)):2 w p,\
'' using (column(0)):2:1 w labels
Here the labels sit directly on top of the points. That may not be what you want -- You can add an offset:
plot 'test.dat' u (column(0)):2:1 w labels offset character 0,1,\
'' u (column(0)):2 w p
From the documentation (help labels), it appears that the appearance of your labels should be able to be modified by pretty much any option that you can pass to set label.
The font, color, rotation angle and other properties of the printed text
may be specified as additional command options (see `set label`).

Y-value on bar graph in gnuplot?

Can I get gnuplot to display the exact y-value or height of a data point (plotted using "with boxes") over its bar? I would like the plot to be easy to read so nobody has to line up the top of a bar with the y-axis and guess what the value is.
You can use the labels style and combine it into the plot command with the boxes style. The labels style expects 3 columns of data - the x coordinate, the y coordinate, and the actual label text.
For example, with the following data
1 4
2 6
3 2
4 8
the command (we set the yrange to 0 - 10 and boxwidth to 0.9 and set a solid fill style)
plot datafile u 1:2 with boxes, "" u 1:2:2 with labels offset char 0,1
produces
Normally, the labels would be centered on the specified point (the top edge of the box). By specifying an offset, we can move them up to just above the box. Here we used no offset in the x direction, but a unit of 1 in the y direction. We used the character coordinate system, so this corresponds to moving up by one character unit.
I can only think of putting the values where you want them "manually" like this:
set label "value" at 12,34
The numbers are coordinates according to your x and y ranges.
An automatic way would use "with labels", see e.g.
http://gnuplot.sourceforge.net/demo_4.4/stringvar.html

Resources