New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
request for plotting variable bin size with imshow #1729
Comments
You can do this with
|
Thanks, in fact it plots the histogram correctly. |
I have found that scipy.interpolate.RectBivariateSpline() to be very fast |
There also looks like there is a |
RectBivariateSpline() sounds interesting, if it is not too complicated to apply, e.g. to the example above. |
On 2013/02/01 11:19 AM, fkbreitl wrote:
There is also the variation on NonUniformImage which is exposed by See http://matplotlib.org/examples/pylab_examples/image_nonuniform.html Eric
|
Oh, this example looks like it might be providing what I was looking for. What a pity I didn't find it earlier. It is probably because this example is completely isolated from the histogram2d examples at the Scipy page and there is also no reference from imshow. That could be an explanation why most people are not aware of it. Adding key words like histogram and variable bin width to the example could maybe make if visible through Google. |
Ok, I worked out an example based on NonUniformImage and added it at Frank |
As discussed at the SciPy developers mailing list there is no simple way to plot 2D histograms with variable bin size (http://mail.scipy.org/pipermail/scipy-dev/2013-January/018271.html). Therefore it was requested that imshow provides such a possibility. The initial email is posted blow:
Hello,
http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram2d.html
explains the usage of 2D histograms.
Although it is possible to construct 2D histograms with a variable bin
size, there is no simple way to plot them.
Therefore I would like to request an implementation to imshow that
allows the visualization of 2D histograms with variable bin size. I
imagine a syntax like
imshow(historgram2d, xedges=xedges, yedges=yedges)
where xedges and yedges are the bin edges along the x- and y-axis.
I have attached a short program and its output which constructs a
numpy.historgram2d with variable bin width (xedges=[0,1,3]) and shows
its bin content with imshow.
I would highly appreciate if imshow would be extended to represent the
histogram correctly.
If there is an alternative solution, I would be interested to learn
about it as well.
Kind regards
Frank
--hist2d.py--
import numpy as np, matplotlib.pyplot as plt
x, y = np.random.randn(2, 10)
x=[2]
y=[0]
xedges=[0,1,3]
yedges=[0,1]
H, yedges, xedges = np.histogram2d(y,x, bins=(yedges,xedges))
extent = [xedges[0], xedges[-1], yedges[-1], yedges[0]]
plt.imshow(H, extent=extent, interpolation='None', aspect='auto')
plt.colorbar()
plt.show()
The text was updated successfully, but these errors were encountered: