In trying to plot a splot-style data file (x,y,z cols) using
plot 'data' u 1:2:3 with image
as a 2d heat map, it looks like the x and y values are being ignored and z's are plotted as if x,y's were integer counters
Please provide an example of your data file.
Without that it is not possibe to say what is going wrong.
Also please tell what version of gnuplot you are using.
Do the x and y coordinates in columns 1 and 2 describe a complete regular grid or are they arbitrary points on an assumed grid, or what?
Depending on what form the data takes, perhaps you would do better to use map it onto a grid using the dgrid3d command and then plot using splot with pm3d.
Or perhaps you will need to provide further information to the program using the matrix keyword.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you very much for your follow-up. Let me try to explain my
concerns further.
I'm using
G N U P L O T
Version 5.4 patchlevel 8 last modified 2023-06-01
(fedora linux)
attached is a data file on a regular, complete grid (log-spaced in both
directions)
plot1.png was produced using the command:
gnuplot> plot 'data' u 1:2:3 w image
it is correct (looks as expected for the z-col data matrix) except for
the labeling of the axes
If i set the axes to be logscale and replot,
gnuplot> set log xy
gnuplot> rep
then i get plot2.png, which shows the ranges of the x,y cols are
correctly recognized, but the plotted image doesnt match up to the
indicated axes
I had been using alternative approaches to generate heat maps (sometimes
in gnuplot,else in matlab) but I really liked the convenience of this
new plot style when i saw it listed on https://gnuplot.sourceforge.net/demo/heatmaps.html
so i hope the axes issues can be fixed....
thank you for reading my input....
tom witelski, duke math dept
On 2023/07/24 12:15 am, Ethan Merritt wrote:
Please provide an example of your data file.
Without that it is not possibe to say what is going wrong.
Also please tell what version of gnuplot you are using.
Do the x and y coordinates in columns 1 and 2 describe a complete
regular grid or are they arbitrary points on an assumed grid, or what?
Depending on what form the data takes, perhaps you would do better to
use map it onto a grid using the dgrid3d command and then plot using
splot with pm3d.
Or perhaps you will need to provide further information to the
program using the matrix keyword.
[SUPPORT-REQUESTS:#286][1] XTICS YTICS IN PLOT WITH IMAGE 2D HEAT
MAPS
STATUS: open
GROUP:
CREATED: Sun Jul 23, 2023 12:07 PM UTC by Thomas Witelski
LAST UPDATED: Sun Jul 23, 2023 12:07 PM UTC
OWNER: nobody
In trying to plot a splot-style data file (x,y,z cols) using
plot 'data' u 1:2:3 with image
as a 2d heat map, it looks like the x and y values are being ignored
and z's are plotted as if x,y's were integer counters
I will try to explain what you are seeing. I am not sure this will actually help you get what you want, but here goes...
The pixels of an image (plot style "with image") are assumed to be of equal size. "Equal size" means equal extend in coordinate space, not necessarily in visual space. The image is assumed to be a regular rectangular array. The program finds the limiting values on x and y, and tries to deduce the dimensions of the rectangle nx and ny. It then splits the xrange into nx equal sections and yrange into ny equal ranges. That is what you see in your plot1.png output. Note that it this case the [x,y] coordinates of interior pixels in your data file contradict the assumption of equal sized pixels; they are essentially ignored.
I don't know where to go from there because I don't know whether the plots you actually want to make use exactly this set of [x,y] coordinates or if this is just a simplified example. If you are happy with plot1.png except for the axis labels, the simplest fix is to provide appropriate labels. The first pixel will be centered at coordinate 1, the last x pixel will be centered at 1000, intermediate pixels will be equally spaced.
set xtics ("1" 1, "10" 333, "100" 666, "1000" 1000)
set ytics ("1" 1, "10" 2500, "100" 5000, "1000" 7500, "10000" 10000)
plot DATA using 1:2:3 with image
It would be possible to have the program calculate these positions by finding the range, taking logs, etc. That could all be done in a script to handle cases other than the one you give as an example (would it always be log spacing?), but for a single case it's easier to just give the positions manually as shown above.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
What you want to draw seems to be a heatmap of equally spaced grids,
regardless of whether the axes are log-scale or not.
Here is a method to generate matrix indexes using pseudo columns in the using specification and using the xtic() and ytic() to use x, y values from data file as axis tic labels.
Thank you very much, this takes care of all of my questions!
best,
tom
On Tue, 25 Jul 2023, Hiroki Motoyoshi wrote:
What you want to draw seems to be a heatmap of equally spaced grids,
regardless of whether the axes are log-scale or not.
Here is a method to generate matrix indexes using pseudo columns in the using specification and using the xtic() and ytic() to use x, y values from data file as axis tic labels.
```
retrieving record number of first block
stat 'data.txt' every :::1::1 nooutput
NY = STATS_records
Status: open Group: Created: Sun Jul 23, 2023 12:07 PM UTC by Thomas Witelski Last Updated: Mon Jul 24, 2023 11:32 PM UTC Owner: nobody
In trying to plot a splot-style data file (x,y,z cols) using
plot 'data' u 1:2:3 with image
as a 2d heat map, it looks like the x and y values are being ignored and z's are plotted as if x,y's were integer counters
Please provide an example of your data file.
Without that it is not possibe to say what is going wrong.
Also please tell what version of gnuplot you are using.
Do the x and y coordinates in columns 1 and 2 describe a complete regular grid or are they arbitrary points on an assumed grid, or what?
Depending on what form the data takes, perhaps you would do better to use map it onto a grid using the dgrid3d command and then plot using
splot with pm3d
.Or perhaps you will need to provide further information to the program using the
matrix
keyword.Thank you very much for your follow-up. Let me try to explain my
concerns further.
I'm using
attached is a data file on a regular, complete grid (log-spaced in both
directions)
plot1.png was produced using the command:
gnuplot> plot 'data' u 1:2:3 w image
it is correct (looks as expected for the z-col data matrix) except for
the labeling of the axes
If i set the axes to be logscale and replot,
gnuplot> set log xy
gnuplot> rep
then i get plot2.png, which shows the ranges of the x,y cols are
correctly recognized, but the plotted image doesnt match up to the
indicated axes
I had been using alternative approaches to generate heat maps (sometimes
in gnuplot,else in matlab) but I really liked the convenience of this
new plot style when i saw it listed on
https://gnuplot.sourceforge.net/demo/heatmaps.html
so i hope the axes issues can be fixed....
thank you for reading my input....
tom witelski, duke math dept
On 2023/07/24 12:15 am, Ethan Merritt wrote:
I will try to explain what you are seeing. I am not sure this will actually help you get what you want, but here goes...
The pixels of an image (plot style "with image") are assumed to be of equal size. "Equal size" means equal extend in coordinate space, not necessarily in visual space. The image is assumed to be a regular rectangular array. The program finds the limiting values on x and y, and tries to deduce the dimensions of the rectangle nx and ny. It then splits the xrange into nx equal sections and yrange into ny equal ranges. That is what you see in your plot1.png output. Note that it this case the [x,y] coordinates of interior pixels in your data file contradict the assumption of equal sized pixels; they are essentially ignored.
Your plot2.png also contains equal-size pixels in coordinate space, but the log scale axes distort this in visual space. For more examples of this see https://gnuplot.sourceforge.net/demo_6.0/nonlinear3.html
I don't know where to go from there because I don't know whether the plots you actually want to make use exactly this set of [x,y] coordinates or if this is just a simplified example. If you are happy with plot1.png except for the axis labels, the simplest fix is to provide appropriate labels. The first pixel will be centered at coordinate 1, the last x pixel will be centered at 1000, intermediate pixels will be equally spaced.
It would be possible to have the program calculate these positions by finding the range, taking logs, etc. That could all be done in a script to handle cases other than the one you give as an example (would it always be log spacing?), but for a single case it's easier to just give the positions manually as shown above.
What you want to draw seems to be a heatmap of equally spaced grids,
regardless of whether the axes are log-scale or not.
Here is a method to generate matrix indexes using pseudo columns in the
using
specification and using thextic()
andytic()
to use x, y values from data file as axis tic labels.If you want to draw border for each cell, the boxxy style is suitable for such a plot.
Thank you very much, this takes care of all of my questions!
best,
tom
On Tue, 25 Jul 2023, Hiroki Motoyoshi wrote:
Related
Support Requests: #286