Gnuplot version: 5.2 patchlevel 5
platform: Linux 4.16.13-041613-generic x86_64 (Linux Mint 18.3)
Hi,
using a 2D heatmap via 'plot ... with image' gives a wrong output if the data are not distributed with a linear binning. It is unclear to me if this is a know effect or a bug.
My input data have the following structure:
1.000000E+00 1 3.720141E+00
1.000000E+00 2 2.098816E+01
....
1.000000E+00 99 2.317764E+03
1.000000E+00 100 2.388149E+03
1.006938E+00 1 3.663303E+00
1.006938E+00 2 2.067914E+01
.............
9.852816E+02 99 2.037077E-03
9.852816E+02 100 2.211063E-03
9.921171E+02 1 1.242277E-18
9.921171E+02 2 3.228117E-16
...
9.921171E+02 99 1.962383E-03
9.921171E+02 100 2.131414E-03
i.e. the x-values are calculated with a log-binning, the y-values are in lin-style.
Plotting the logarithmic this data set with a linear x-scale and changing the scale (by hand -> Incscape) to a logarithmic scaling gives the correct result.
Uh, typo: I meant "Plotting this data set with a linear x-scale and changing the scale (by hand -> Incscape) to a logarithmic scaling gives the correct result."
DataLinBin_linscaleX.png and DataLinBin_logscaleX.png show a correct result.
DataLogBin_linscaleX.png shows the same image as DataLinBin_logscaleX.png but with a wrong x-axis.
Changing the x-axis scaling to log-style changes the data image -> DataLogBin_logscaleX.png.
Is there a way to change only the X-axis, but not the data? This wouldn't be a clean solution, but a quick and dirty work around...
This one seems to have slipped through a crack. I don't remember ever looking at it, but now that I do look at it I don't understand what exactly is being tried. In particular I don't understand what "binning" means in the context of "plot with image". Can you please attach a script and if necessary an associated data file that demonstrate the failure?
I found the same problem and made the simplest example I could think of.
If you look at the file "2d-exp.data" you'll see that the x-values are 10, 100, 1'000, 10'000 and 100'000
but in the plot the first bin occupies roughly [10:10'000], the second bin [10k:40k], the third bin [40k:60k], the fourth bin [60k:80k] and the last bin [80k:105k]
I verified that with gnuplot 5.2 patchlevel 8 on Debian Bullseye (5.4.1+dfsg1-1) and with the latest git version (40a9029b292812cd5a69134b140841746767a93b)
I think the simplest answer is that "with image" is not an appropriate plot style for data in this form. The very first sentence in the documentation for
with imagenotes that it assumes a uniformly sampled grid.Using
with pm3dwould come closer to your intent:However there is a fundamental difference between the component pixels of an
imageplot and apm3dplot. The former creates a uniformly sized box centered at each data point (which is why the data must be equally spaced). One pixel is created for each data point. The latter treats the coordinates as defining the corners of a set of boxes, possibly of varying size. Because each box needs both a low and a high coordinate in each direction, NxM data points produce (N-1)x(M-1) boxes.For this particular case you could manipulate the data to restore uniform spacing and then artificially label the plot to show an exponential range. I cannot say whether the result accurately presents what you need to show:
Last edit: Ethan Merritt 2021-01-31
Thank you, that was very helpful. I wanted to report that pm3d has the disadvantage (compared to image) that if I set the xrange to start or end in the middle of a "pixel" that rectangle doesn't get plotted but it is fixed in the git version I tried.
Therefore all my current problems with gnuplot have been solved :-)
Regarding the behavior of plotting with image I think it would be nice if there was a warning for non-regular spaced grids.
I made more examples showcasing what I expected:
First, a 1D example
Now, the 2D example:
I manually labeled the x-axis (2d-workaround.gpl/png) to show the plot I would have expected.