2D histogram: request for plotting variable bin size

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

On Thu, Jan 31, 2013 at 9:01 AM, Frank Breitling <fbreitling@aip.de> wrote:
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.
This may be a discussion for matplotlib-user, but have you had a look at trying to use broken_barh for your needs? http://matplotlib.org/examples/pylab_examples/broken_barh.html Skipper

Hi Skipper, I would like to use Python for plotting dynamic radio spectra e.g. as found at http://science.nasa.gov/media/medialibrary/1998/12/20/ast22dec98_1_resources... (Image is also attached). Given the high resolution in time and frequency I believe broken_barh is not suited. But thanks for your suggestion Frank On 31.01.2013 15:17, Skipper Seabold wrote:
On Thu, Jan 31, 2013 at 9:01 AM, Frank Breitling <fbreitling@aip.de <mailto:fbreitling@aip.de>> wrote:
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.
This may be a discussion for matplotlib-user, but have you had a look at trying to use broken_barh for your needs?
http://matplotlib.org/examples/pylab_examples/broken_barh.html
Skipper
_______________________________________________ SciPy-Dev mailing list SciPy-Dev@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-dev

On Thu, Jan 31, 2013 at 10:00 AM, Frank Breitling <fbreitling@aip.de> wrote:
Hi Skipper,
I would like to use Python for plotting dynamic radio spectra e.g. as found at
http://science.nasa.gov/media/medialibrary/1998/12/20/ast22dec98_1_resources...
(Image is also attached). Given the high resolution in time and frequency I believe broken_barh is not suited.
But thanks for your suggestion
Sure. I wasn't entirely clear on what you were after. Sturla's answer is much better suited. Skipper

Hi Frank I use Python to plot wavelet spectrograms with logarithmically scaled frequencies. I e.g. interpolate the spectrum to the frequencies I like to plot, and pass that to pcolor or contourf. Usually I plot with a linear y-axis first, and then use set_yscale('log'). Usually the y-axis must be flipped too. Then I e.g. end up with something like this, plotting with 250 logartihmically scaled frequencies from 10 Hz to 10 kHz: cwt,scale= wavelet(signal, sampling_rate) time = np.arange(signal.shape[0])/sampling_rate power = np.abs(cwt)**2/scale # bias corrected power periods = wavelet_to_fourier(scale) spectrum_freqs = np.logspace(np.log10(10), np.log10(10000), 250) spectrum_periods = spectrum_freqs**-1 spectrum = interpolate_spectrum(spectrum_periods, power, periods) X,Y = np.meshgrid(time, spectrum_freqs) cs = plt.contourf(X,Y,spectrum, cmap=cm.jet, origin=origin) ax = plt.gca() ax.set_yscale('log') ylim = ax.get_ylim() ax.set_ylim(ylim[::-1]) import numpy as np from bisect import bisect_left def interpolate_spectrum(spectrum_periods, wavelet_power, wavelet_periods): """ linear interpolation for plotting spectrum at given frequencies """ n0 = spectrum_periods.shape[0] n1 = wavelet_power.shape[1] m = wavelet_power.shape[0] spectrum_power = np.zeros((n0,n1)) for k,sp in enumerate(spectrum_periods): i = bisect_left(wavelet_periods,sp) j = i-1 i = 0 if i<0 else i i = m-1 if i > m-1 else i j = 0 if j<0 else j j = m-1 if j > m-1 else j eps = 1E-5 # avoid log of zero di = 1./(np.abs(sp - wavelet_periods[i]) + eps) dj = 1./(np.abs(sp - wavelet_periods[j]) + eps) spectrum_power[k,:] = (di*wavelet_power[i,:] + dj*wavelet_power[j,:])/(di+dj) return spectrum_power Not sure if this helps or not, but it might. Sturla On 31.01.2013 16:00, Frank Breitling wrote:
Hi Skipper,
I would like to use Python for plotting dynamic radio spectra e.g. as found at
http://science.nasa.gov/media/medialibrary/1998/12/20/ast22dec98_1_resources...
(Image is also attached). Given the high resolution in time and frequency I believe broken_barh is not suited.
But thanks for your suggestion
Frank
On 31.01.2013 15:17, Skipper Seabold wrote:
On Thu, Jan 31, 2013 at 9:01 AM, Frank Breitling <fbreitling@aip.de <mailto:fbreitling@aip.de>> wrote:
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.
This may be a discussion for matplotlib-user, but have you had a look at trying to use broken_barh for your needs?
http://matplotlib.org/examples/pylab_examples/broken_barh.html
Skipper
_______________________________________________ SciPy-Dev mailing list SciPy-Dev@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-dev
_______________________________________________ SciPy-Dev mailing list SciPy-Dev@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-dev

On 31.01.2013 15:01, Frank Breitling wrote:
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)
This is question about matplotlib, not SciPy. However, matplotlib.pyplot.pcolor will do what you want. Sturla

On 31.01.2013 15:49, Sturla Molden wrote:
imshow(historgram2d, xedges=xedges, yedges=yedges)
This is question about matplotlib, not SciPy.
However, matplotlib.pyplot.pcolor will do what you want.
And if the 2D histogram is very large, matplotlib.pyplot.pcolormesh will be faster. The purpose of imshow is to display images. Sturla

Hi Sturla, My experience with pcolor was that is was very slow. Pcolormesh was significantly faster but compared to imshow is still very slow. However, while imshow produces smooth interpolations between the discrete frequencies I didn't find a similar option with pcolormesh and so the results were not useful. You can see it in the imshow and pcolormesh images attached. Frank On 31.01.2013 15:55, Sturla Molden wrote:
On 31.01.2013 15:49, Sturla Molden wrote:
imshow(historgram2d, xedges=xedges, yedges=yedges) This is question about matplotlib, not SciPy.
However, matplotlib.pyplot.pcolor will do what you want. And if the 2D histogram is very large, matplotlib.pyplot.pcolormesh will be faster.
The purpose of imshow is to display images.
Sturla
_______________________________________________ SciPy-Dev mailing list SciPy-Dev@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-dev

On 31.01.2013 16:32, Frank Breitling wrote:
My experience with pcolor was that is was very slow.
imshow is fast because it basically just bitblit the image. You can always use Python (or Cython, Fortran or C) to prepare an image from your 2D data and pass that to imshow. I showed you can example where I used contourf. I kind of show too, but I often just let the computer run for a while and prepare a bunch of PDF files with the spectrums. Then I can take those into e.g. Adobe Illustrator later on, and I will also store the wavelet data in PyTables (HDF5) files. If I needed to render a spectrum in "real-time", I would use imshow or OpenGL, and e.g. have my own Fortran 90 code prepare the displayed image. I might even consider to use PyOpenGL to write vertex shaders and have the graphics hardware do all the rendering. So it really depends on how fast you need it to be. Python code can draw your data with OpenGL at the full speed that your graphics hardware allows. Or you can settle for slower but more convenient data visualization methods like pcolor and contourf. Or you can do something in between. But as for the question you asked (how to draw a 2D historgram), pcolor does exactly that. I did not say it will be fast for huge data sets. I thought you were used to e.g. Matlab and wanted something like image or imagesc, and then found imshow but overlooked pcolor. :-) Sturla

And I must apologize to the rest of you for posting this OT material on the SciPy dev list. I know what this list is for. Sorry for the spam :) Sturla On 31.01.2013 16:56, Sturla Molden wrote:
On 31.01.2013 16:32, Frank Breitling wrote:
My experience with pcolor was that is was very slow.
imshow is fast because it basically just bitblit the image. You can always use Python (or Cython, Fortran or C) to prepare an image from your 2D data and pass that to imshow.
I showed you can example where I used contourf. I kind of show too, but I often just let the computer run for a while and prepare a bunch of PDF files with the spectrums. Then I can take those into e.g. Adobe Illustrator later on, and I will also store the wavelet data in PyTables (HDF5) files.
If I needed to render a spectrum in "real-time", I would use imshow or OpenGL, and e.g. have my own Fortran 90 code prepare the displayed image. I might even consider to use PyOpenGL to write vertex shaders and have the graphics hardware do all the rendering.
So it really depends on how fast you need it to be. Python code can draw your data with OpenGL at the full speed that your graphics hardware allows. Or you can settle for slower but more convenient data visualization methods like pcolor and contourf. Or you can do something in between.
But as for the question you asked (how to draw a 2D historgram), pcolor does exactly that. I did not say it will be fast for huge data sets. I thought you were used to e.g. Matlab and wanted something like image or imagesc, and then found imshow but overlooked pcolor.
:-)
Sturla _______________________________________________ SciPy-Dev mailing list SciPy-Dev@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-dev

Hi Strula, Thank you very much for your answer and examples. What I understand form them is that there is currently no simple and fast method for plotting 2D histograms with variable bin width. Therefore I would like to come back to my initial feature request for imshow. It seems to me that with an implementation of a variable bin width all other solutions would collapse into a one-liner providing even best performance. From a technical perspective I understand that the philosophy behind imshow is to keep it simple to maintain its high speed. On the other hand a smart implementation of a variable bin width should at most result in a small penalty at the start of the execution. Therefore I would like to confirm my feature request to imshow. However, since this is a matplotlib issue (as you pointed out before), I should probably file it at their trackers. Thanks again for your replies Frank On 31.01.2013 16:56, Sturla Molden wrote:
On 31.01.2013 16:32, Frank Breitling wrote:
My experience with pcolor was that is was very slow. imshow is fast because it basically just bitblit the image. You can always use Python (or Cython, Fortran or C) to prepare an image from your 2D data and pass that to imshow.
I showed you can example where I used contourf. I kind of show too, but I often just let the computer run for a while and prepare a bunch of PDF files with the spectrums. Then I can take those into e.g. Adobe Illustrator later on, and I will also store the wavelet data in PyTables (HDF5) files.
If I needed to render a spectrum in "real-time", I would use imshow or OpenGL, and e.g. have my own Fortran 90 code prepare the displayed image. I might even consider to use PyOpenGL to write vertex shaders and have the graphics hardware do all the rendering.
So it really depends on how fast you need it to be. Python code can draw your data with OpenGL at the full speed that your graphics hardware allows. Or you can settle for slower but more convenient data visualization methods like pcolor and contourf. Or you can do something in between.
But as for the question you asked (how to draw a 2D historgram), pcolor does exactly that. I did not say it will be fast for huge data sets. I thought you were used to e.g. Matlab and wanted something like image or imagesc, and then found imshow but overlooked pcolor.
:-)
Sturla _______________________________________________ SciPy-Dev mailing list SciPy-Dev@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-dev

On 01.02.2013 11:36, Frank Breitling wrote:
Thank you very much for your answer and examples. What I understand form them is that there is currently no simple and fast method for plotting 2D histograms with variable bin width.
Not, not simple and fast (unless you work with something else than matplotlib).
Therefore I would like to come back to my initial feature request for imshow. It seems to me that with an implementation of a variable bin width all other solutions would collapse into a one-liner providing even best performance. From a technical perspective I understand that the philosophy behind imshow is to keep it simple to maintain its high speed. On the other hand a smart implementation of a variable bin width should at most result in a small penalty at the start of the execution.
Digital images and computer screens do not have variable pixel size. imshow plots images. The speed is a coincidence and not very relevant. A feature request for drawing images with variable pixel size will probably be discarded as invalid. It sounds like you want a faster pcolor or pcolormesh. They will probably be happy if you can help with it. A feature request for a faster pcolor and pcolormesh might have a better chance of surviving. Sturla

Hi, From the matplotlib developers it was pointed out, that there is a NonUniformImage which might be suite for representing interpolated variable bin size 2D histograms (https://github.com/matplotlib/matplotlib/issues/1729#issuecomment-13014723). There even exists an example (http://matplotlib.org/examples/pylab_examples/image_nonuniform.html) but it is very isolated and therefore not well known. It would be very useful to explain its usage or at least link to it in the histogram2d example at http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram2d.html. In addition a pcolor example (attached below) shouldn't be missing. Even though it is slow and can't do interpolation, it can at least do a correct representation for academic purposes. Can anybody do that or would you like me to do that myself? Frank --- import numpy as np, matplotlib.pyplot as plt 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]] X,Y = np.meshgrid(xedges, yedges) plt.pcolor(X, Y, H) plt.colorbar() plt.show()

On 02.02.2013 10:53, Frank Breitling wrote:
Hi,
From the matplotlib developers it was pointed out, that there is a NonUniformImage which might be suite for representing interpolated variable bin size 2D histograms (https://github.com/matplotlib/matplotlib/issues/1729#issuecomment-13014723). There even exists an example (http://matplotlib.org/examples/pylab_examples/image_nonuniform.html) but it is very isolated and therefore not well known. It would be very useful to explain its usage or at least link to it in the histogram2d example at http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram2d.html.
In addition a pcolor example (attached below) shouldn't be missing. Even though it is slow and can't do interpolation, it can at least do a correct representation for academic purposes.
Can anybody do that or would you like me to do that myself?
Frank
Since it is at the top of your head, why don't you do it? But it might be better for the SciPy Cookbook's matplotlib section than the NumPy docs. I'm not sure if they want matplotlib examples in the NumPy documentation (ask on the NumPy list before you waste your time on it). http://www.scipy.org/Cookbook/Matplotlib Sturla

Hi, So I registered an account, but I have to request write permission by email to scipy-dev@scipy.org first. So could somebody give me write permission to the page http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram2d.html and maybe also to http://www.scipy.org/Cookbook/Matplotlib ? Or otherwise could somebody add the example below for me? Frank --- import numpy as np, matplotlib.pyplot as plt x = np.random.normal(3, 2, 1000) y = np.random.normal(3, 1, 1000) yedges=xedges=[0,2,3,4,6] H, yedges, xedges = np.histogram2d(y,x, bins=(yedges,xedges)) extent = [xedges[0], xedges[-1], yedges[-1], yedges[0]] #If bin size is equal imshow can be used. It is fast and provides interpolation. #plt.imshow(H, extent=extent, interpolation='None', aspect='auto') #To display variable bin size pcolar can be used X,Y = np.meshgrid(xedges, yedges) plt.pcolor(X, Y, H) #If interpolation is needed in addition matplotlib provides the NonUniformImage: #http://matplotlib.org/examples/pylab_examples/image_nonuniform.html plt.colorbar() plt.show() On 2013-02-02 16:44, Sturla Molden wrote:
On 02.02.2013 10:53, Frank Breitling wrote:
Hi,
From the matplotlib developers it was pointed out, that there is a NonUniformImage which might be suite for representing interpolated variable bin size 2D histograms (https://github.com/matplotlib/matplotlib/issues/1729#issuecomment-13014723). There even exists an example (http://matplotlib.org/examples/pylab_examples/image_nonuniform.html) but it is very isolated and therefore not well known. It would be very useful to explain its usage or at least link to it in the histogram2d example at http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram2d.html.
In addition a pcolor example (attached below) shouldn't be missing. Even though it is slow and can't do interpolation, it can at least do a correct representation for academic purposes.
Can anybody do that or would you like me to do that myself?
Frank Since it is at the top of your head, why don't you do it?
But it might be better for the SciPy Cookbook's matplotlib section than the NumPy docs. I'm not sure if they want matplotlib examples in the NumPy documentation (ask on the NumPy list before you waste your time on it).
http://www.scipy.org/Cookbook/Matplotlib
Sturla
_______________________________________________ SciPy-Dev mailing list SciPy-Dev@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-dev

That is not how it works. If you have a suggestion for changing the NumPy (including docs) you fork NumPy on GitHub.com and post a pull-request with your changes. And that would be after asking on the NumPy list (not on scipy-dev!). They might also want you to open an issue on their GitHub tracker. All users on scipy.org should be able to update the cookbook. At least that it how it worked before. If you want to create a new page on the wiki you just navigate to it with your browser. Sturla On 02.02.2013 20:59, Frank Breitling wrote:
Hi,
So I registered an account, but I have to request write permission by email to scipy-dev@scipy.org first. So could somebody give me write permission to the page http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram2d.html and maybe also to http://www.scipy.org/Cookbook/Matplotlib ?
Or otherwise could somebody add the example below for me?
Frank
--- import numpy as np, matplotlib.pyplot as plt
x = np.random.normal(3, 2, 1000) y = np.random.normal(3, 1, 1000)
yedges=xedges=[0,2,3,4,6]
H, yedges, xedges = np.histogram2d(y,x, bins=(yedges,xedges)) extent = [xedges[0], xedges[-1], yedges[-1], yedges[0]]
#If bin size is equal imshow can be used. It is fast and provides interpolation. #plt.imshow(H, extent=extent, interpolation='None', aspect='auto')
#To display variable bin size pcolar can be used X,Y = np.meshgrid(xedges, yedges) plt.pcolor(X, Y, H)
#If interpolation is needed in addition matplotlib provides the NonUniformImage: #http://matplotlib.org/examples/pylab_examples/image_nonuniform.html
plt.colorbar() plt.show()
On 2013-02-02 16:44, Sturla Molden wrote:
On 02.02.2013 10:53, Frank Breitling wrote:
Hi,
From the matplotlib developers it was pointed out, that there is a NonUniformImage which might be suite for representing interpolated variable bin size 2D histograms (https://github.com/matplotlib/matplotlib/issues/1729#issuecomment-13014723). There even exists an example (http://matplotlib.org/examples/pylab_examples/image_nonuniform.html) but it is very isolated and therefore not well known. It would be very useful to explain its usage or at least link to it in the histogram2d example at http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram2d.html.
In addition a pcolor example (attached below) shouldn't be missing. Even though it is slow and can't do interpolation, it can at least do a correct representation for academic purposes.
Can anybody do that or would you like me to do that myself?
Frank Since it is at the top of your head, why don't you do it?
But it might be better for the SciPy Cookbook's matplotlib section than the NumPy docs. I'm not sure if they want matplotlib examples in the NumPy documentation (ask on the NumPy list before you waste your time on it).
http://www.scipy.org/Cookbook/Matplotlib
Sturla
_______________________________________________ SciPy-Dev mailing list SciPy-Dev@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-dev
_______________________________________________ SciPy-Dev mailing list SciPy-Dev@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-dev

That is not how it works.
If you have a suggestion for changing the NumPy (including docs) you fork NumPy on GitHub.com and post a pull-request with your changes. And that would be after asking on the NumPy list (not on scipy-dev!). They might also want you to open an issue on their GitHub tracker. Oh, that sounds complicated. But the edit link on the left at http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram2d.html and the instruction to ask for write permission through the scipy-dev@scipy.org suggest that one should be able to edit this page
On 2013-02-02 21:52, Sturla Molden wrote: directly? Unfortunately my registration for the http://www.scipy.org/Cookbook/Matplotlib/UnfilledHistograms three hours ago timed out with the following message: "Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, root@enthought.com and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log." Meanwhile I haven't received an answer from the root@enthought.com. After all the threshold for a contribution seems quite high. Frank

On 02.02.2013 22:37, Frank Breitling wrote:
But the edit link on the left at http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram2d.html and the instruction to ask for write permission through the scipy-dev@scipy.org suggest that one should be able to edit this page directly?
It believe it is generated from this: https://github.com/numpy/numpy/tree/master/doc Sturla

Hi, It seems like my account for the cookbook is working now. But when clicking on create new page http://www.scipy.org/Cookbook/Histograms?action=edit I received the error below. I don't know how to fix this. Frank --- OSError [Errno 31] Too many links: '/home/scipy/wiki/data/pages/Cookbook(2f)Histograms' If you want to report a bug, please save this page and attach it to your bug report. Show debugging information Report bug Visit MoinMoin wiki Traceback A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred. /usr/lib/python2.4/site-packages/MoinMoin/request.py in run (self=<MoinMoin.request.RequestFastCGI object>) 1149 from MoinMoin.wikiaction import getHandler 1150 handler = getHandler(self, action) 1151 handler(self.page.page_name, self) 1152 1153 # generate page footer (actions that do not want this footer use handler = <function do_edit> self = <MoinMoin.request.RequestFastCGI object> self.page = <MoinMoin.Page.Page instance> self.page.page_name = u'Cookbook/Histograms' /usr/lib/python2.4/site-packages/MoinMoin/wikiaction.py in do_edit (pagename=u'Cookbook/Histograms', request=<MoinMoin.request.RequestFastCGI object>) 580 # is invoked without savetext start editing 581 if savetext is None: 582 pg.sendEditor() 583 return 584 pg = <MoinMoin.PageEditor.PageEditor instance> pg.sendEditor = <bound method PageEditor.sendEditor of <MoinMoin.PageEditor.PageEditor instance>> /usr/lib/python2.4/site-packages/MoinMoin/PageEditor.py in sendEditor (self=<MoinMoin.PageEditor.PageEditor instance>, **kw={}) 176 except OSError, err: 177 if err.errno != errno.ENAMETOOLONG: 178 raise err 179 msg = _("Page name is too long, try shorter name.") 180 err = <exceptions.OSError instance> OSError [Errno 31] Too many links: '/home/scipy/wiki/data/pages/Cookbook(2f)Histograms' args = (31, 'Too many links') errno = 31 filename = '/home/scipy/wiki/data/pages/Cookbook(2f)Histograms' strerror = 'Too many links' System Details Date: Sun, 03 Feb 2013 09:15:15 +0000 Platform: Linux scipy.org 2.6.32-4-pve #1 SMP Thu Oct 21 09:35:29 CEST 2010 i686 Python: Python 2.4.3 (/usr/bin/python) MoinMoin: Release 1.5.6 (release) Am 02.02.2013 22:47, schrieb Sturla Molden:
On 02.02.2013 22:37, Frank Breitling wrote:
But the edit link on the left at http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram2d.html and the instruction to ask for write permission through the scipy-dev@scipy.org suggest that one should be able to edit this page directly?
It believe it is generated from this:
https://github.com/numpy/numpy/tree/master/doc
Sturla
_______________________________________________ SciPy-Dev mailing list SciPy-Dev@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-dev

Hi, And how can I add or update images of the numpy doc (e.g. at http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram2d.html)? Meanwhile I have created an example for histograms with variable bin size at http://www.scipy.org/Cookbook/Histograms and would like to add this to the numpy doc, too. Therefore I need to replace the image. Frank On 02.02.2013 21:52, Sturla Molden wrote:
That is not how it works.
If you have a suggestion for changing the NumPy (including docs) you fork NumPy on GitHub.com and post a pull-request with your changes. And that would be after asking on the NumPy list (not on scipy-dev!). They might also want you to open an issue on their GitHub tracker.
All users on scipy.org should be able to update the cookbook. At least that it how it worked before. If you want to create a new page on the wiki you just navigate to it with your browser.
Sturla
On 02.02.2013 20:59, Frank Breitling wrote:
Hi,
So I registered an account, but I have to request write permission by email to scipy-dev@scipy.org first. So could somebody give me write permission to the page http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram2d.html and maybe also to http://www.scipy.org/Cookbook/Matplotlib ?
Or otherwise could somebody add the example below for me?
Frank
--- import numpy as np, matplotlib.pyplot as plt
x = np.random.normal(3, 2, 1000) y = np.random.normal(3, 1, 1000)
yedges=xedges=[0,2,3,4,6]
H, yedges, xedges = np.histogram2d(y,x, bins=(yedges,xedges)) extent = [xedges[0], xedges[-1], yedges[-1], yedges[0]]
#If bin size is equal imshow can be used. It is fast and provides interpolation. #plt.imshow(H, extent=extent, interpolation='None', aspect='auto')
#To display variable bin size pcolar can be used X,Y = np.meshgrid(xedges, yedges) plt.pcolor(X, Y, H)
#If interpolation is needed in addition matplotlib provides the NonUniformImage: #http://matplotlib.org/examples/pylab_examples/image_nonuniform.html
plt.colorbar() plt.show()
On 2013-02-02 16:44, Sturla Molden wrote:
On 02.02.2013 10:53, Frank Breitling wrote:
Hi,
From the matplotlib developers it was pointed out, that there is a NonUniformImage which might be suite for representing interpolated variable bin size 2D histograms (https://github.com/matplotlib/matplotlib/issues/1729#issuecomment-13014723). There even exists an example (http://matplotlib.org/examples/pylab_examples/image_nonuniform.html) but it is very isolated and therefore not well known. It would be very useful to explain its usage or at least link to it in the histogram2d example at http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram2d.html.
In addition a pcolor example (attached below) shouldn't be missing. Even though it is slow and can't do interpolation, it can at least do a correct representation for academic purposes.
Can anybody do that or would you like me to do that myself?
Frank Since it is at the top of your head, why don't you do it?
But it might be better for the SciPy Cookbook's matplotlib section than the NumPy docs. I'm not sure if they want matplotlib examples in the NumPy documentation (ask on the NumPy list before you waste your time on it).
http://www.scipy.org/Cookbook/Matplotlib
Sturla
_______________________________________________ SciPy-Dev mailing list SciPy-Dev@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-dev
_______________________________________________ SciPy-Dev mailing list SciPy-Dev@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-dev
_______________________________________________ SciPy-Dev mailing list SciPy-Dev@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-dev

On Tue, Mar 26, 2013 at 11:15 AM, Frank Breitling <fbreitling@aip.de> wrote:
Hi,
And how can I add or update images of the numpy doc (e.g. at http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram2d.html )?
That's created by the example code in the histogram2d docstring. So you can add an example in that docstring in your own numpy git repo, then send a PR with that change on Github. Ralf
Meanwhile I have created an example for histograms with variable bin size at http://www.scipy.org/Cookbook/Histograms and would like to add this to the numpy doc, too. Therefore I need to replace the image.
Frank
On 02.02.2013 21:52, Sturla Molden wrote:
That is not how it works.
If you have a suggestion for changing the NumPy (including docs) you fork NumPy on GitHub.com and post a pull-request with your changes. And that would be after asking on the NumPy list (not on scipy-dev!). They might also want you to open an issue on their GitHub tracker.
All users on scipy.org should be able to update the cookbook. At least that it how it worked before. If you want to create a new page on the wiki you just navigate to it with your browser.
Sturla
On 02.02.2013 20:59, Frank Breitling wrote:
Hi,
So I registered an account, but I have to request write permission by email to scipy-dev@scipy.org first. So could somebody give me write permission to the page
http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram2d.html
and maybe also to http://www.scipy.org/Cookbook/Matplotlib ?
Or otherwise could somebody add the example below for me?
Frank
--- import numpy as np, matplotlib.pyplot as plt
x = np.random.normal(3, 2, 1000) y = np.random.normal(3, 1, 1000)
yedges=xedges=[0,2,3,4,6]
H, yedges, xedges = np.histogram2d(y,x, bins=(yedges,xedges)) extent = [xedges[0], xedges[-1], yedges[-1], yedges[0]]
#If bin size is equal imshow can be used. It is fast and provides interpolation. #plt.imshow(H, extent=extent, interpolation='None', aspect='auto')
#To display variable bin size pcolar can be used X,Y = np.meshgrid(xedges, yedges) plt.pcolor(X, Y, H)
#If interpolation is needed in addition matplotlib provides the NonUniformImage: #http://matplotlib.org/examples/pylab_examples/image_nonuniform.html
plt.colorbar() plt.show()
On 2013-02-02 16:44, Sturla Molden wrote:
On 02.02.2013 10:53, Frank Breitling wrote:
Hi,
From the matplotlib developers it was pointed out, that there is a NonUniformImage which might be suite for representing interpolated variable bin size 2D histograms ( https://github.com/matplotlib/matplotlib/issues/1729#issuecomment-13014723 ). There even exists an example (http://matplotlib.org/examples/pylab_examples/image_nonuniform.html) but it is very isolated and therefore not well known. It would be very useful to explain its usage or at least link to it in the histogram2d example at
http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram2d.html .
In addition a pcolor example (attached below) shouldn't be missing.
Even
though it is slow and can't do interpolation, it can at least do a correct representation for academic purposes.
Can anybody do that or would you like me to do that myself?
Frank Since it is at the top of your head, why don't you do it?
But it might be better for the SciPy Cookbook's matplotlib section than the NumPy docs. I'm not sure if they want matplotlib examples in the NumPy documentation (ask on the NumPy list before you waste your time on it).
http://www.scipy.org/Cookbook/Matplotlib
Sturla
_______________________________________________ SciPy-Dev mailing list SciPy-Dev@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-dev
_______________________________________________ SciPy-Dev mailing list SciPy-Dev@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-dev
_______________________________________________ SciPy-Dev mailing list SciPy-Dev@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-dev
_______________________________________________ SciPy-Dev mailing list SciPy-Dev@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-dev

Thanks Ralf, So is there no simple way to test changes before the commit? Frank On 26.03.2013 19:33, Ralf Gommers wrote:
On Tue, Mar 26, 2013 at 11:15 AM, Frank Breitling <fbreitling@aip.de <mailto:fbreitling@aip.de>> wrote:
Hi,
And how can I add or update images of the numpy doc (e.g. at http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram2d.html)?
That's created by the example code in the histogram2d docstring. So you can add an example in that docstring in your own numpy git repo, then send a PR with that change on Github.
Ralf
Meanwhile I have created an example for histograms with variable bin size at http://www.scipy.org/Cookbook/Histograms and would like to add this to the numpy doc, too. Therefore I need to replace the image.
Frank
On 02.02.2013 21:52, Sturla Molden wrote: > That is not how it works. > > If you have a suggestion for changing the NumPy (including docs) you > fork NumPy on GitHub.com and post a pull-request with your changes. And > that would be after asking on the NumPy list (not on scipy-dev!). > They might also want you to open an issue on their GitHub tracker. > > All users on scipy.org <http://scipy.org> should be able to update the cookbook. At least > that it how it worked before. If you want to create a new page on the > wiki you just navigate to it with your browser. > > Sturla > > > On 02.02.2013 20:59, Frank Breitling wrote: >> Hi, >> >> So I registered an account, but I have to request write permission by >> email to scipy-dev@scipy.org <mailto:scipy-dev@scipy.org> first. >> So could somebody give me write permission to the page >> http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram2d.html >> and maybe also to http://www.scipy.org/Cookbook/Matplotlib ? >> >> Or otherwise could somebody add the example below for me? >> >> Frank >> >> --- >> import numpy as np, matplotlib.pyplot as plt >> >> x = np.random.normal(3, 2, 1000) >> y = np.random.normal(3, 1, 1000) >> >> yedges=xedges=[0,2,3,4,6] >> >> H, yedges, xedges = np.histogram2d(y,x, bins=(yedges,xedges)) >> extent = [xedges[0], xedges[-1], yedges[-1], yedges[0]] >> >> #If bin size is equal imshow can be used. It is fast and provides >> interpolation. >> #plt.imshow(H, extent=extent, interpolation='None', >> aspect='auto') >> >> #To display variable bin size pcolar can be used >> X,Y = np.meshgrid(xedges, yedges) >> plt.pcolor(X, Y, >> H) >> >> #If interpolation is needed in addition matplotlib provides the >> NonUniformImage: >> #http://matplotlib.org/examples/pylab_examples/image_nonuniform.html >> >> plt.colorbar() >> plt.show() >> >> >> >> On 2013-02-02 16:44, Sturla Molden wrote: >>> On 02.02.2013 10:53, Frank Breitling wrote: >>>> Hi, >>>> >>>> From the matplotlib developers it was pointed out, that there is a >>>> NonUniformImage which might be suite for representing interpolated >>>> variable bin size 2D histograms >>>> (https://github.com/matplotlib/matplotlib/issues/1729#issuecomment-13014723). >>>> There even exists an example >>>> (http://matplotlib.org/examples/pylab_examples/image_nonuniform.html) >>>> but it is very isolated and therefore not well known. >>>> It would be very useful to explain its usage or at least link to it in >>>> the histogram2d example at >>>> http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram2d.html. >>>> >>>> In addition a pcolor example (attached below) shouldn't be missing. Even >>>> though it is slow and can't do interpolation, it can at least do a >>>> correct representation for academic purposes. >>>> >>>> Can anybody do that or would you like me to do that myself? >>>> >>>> Frank >>> Since it is at the top of your head, why don't you do it? >>> >>> But it might be better for the SciPy Cookbook's matplotlib section >>> than the NumPy docs. I'm not sure if they want matplotlib examples in >>> the NumPy documentation (ask on the NumPy list before you waste your >>> time on it). >>> >>> >>> http://www.scipy.org/Cookbook/Matplotlib >>> >>> >>> >>> Sturla >>> >>> >>> _______________________________________________ >>> SciPy-Dev mailing list >>> SciPy-Dev@scipy.org <mailto:SciPy-Dev@scipy.org> >>> http://mail.scipy.org/mailman/listinfo/scipy-dev >>> >> _______________________________________________ >> SciPy-Dev mailing list >> SciPy-Dev@scipy.org <mailto:SciPy-Dev@scipy.org> >> http://mail.scipy.org/mailman/listinfo/scipy-dev >> > _______________________________________________ > SciPy-Dev mailing list > SciPy-Dev@scipy.org <mailto:SciPy-Dev@scipy.org> > http://mail.scipy.org/mailman/listinfo/scipy-dev >
_______________________________________________ SciPy-Dev mailing list SciPy-Dev@scipy.org <mailto:SciPy-Dev@scipy.org> http://mail.scipy.org/mailman/listinfo/scipy-dev
_______________________________________________ SciPy-Dev mailing list SciPy-Dev@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-dev

On Wed, Mar 27, 2013 at 11:14 AM, Frank Breitling <fbreitling@aip.de> wrote:
Thanks Ralf,
So is there no simple way to test changes before the commit?
Sure there is. One way is: 1. build numpy in-place (python setup.py build_ext -i) and add it to your PYTHONPATH. (alternatively: python setup.py develop) 2. edit the docstring 3. "make html in the doc/ directory 4. the built docs are now in doc/build/html, view the result in your browser (5. if the result looks good, commit it and send a PR) Cheers, Ralf
Frank
On 26.03.2013 19:33, Ralf Gommers wrote:
On Tue, Mar 26, 2013 at 11:15 AM, Frank Breitling <fbreitling@aip.de>wrote:
Hi,
And how can I add or update images of the numpy doc (e.g. at http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram2d.html )?
That's created by the example code in the histogram2d docstring. So you can add an example in that docstring in your own numpy git repo, then send a PR with that change on Github.
Ralf
Meanwhile I have created an example for histograms with variable bin size at http://www.scipy.org/Cookbook/Histograms and would like to add this to the numpy doc, too. Therefore I need to replace the image.
Frank
On 02.02.2013 21:52, Sturla Molden wrote:
That is not how it works.
If you have a suggestion for changing the NumPy (including docs) you fork NumPy on GitHub.com and post a pull-request with your changes. And that would be after asking on the NumPy list (not on scipy-dev!). They might also want you to open an issue on their GitHub tracker.
All users on scipy.org should be able to update the cookbook. At least that it how it worked before. If you want to create a new page on the wiki you just navigate to it with your browser.
Sturla
On 02.02.2013 20:59, Frank Breitling wrote:
Hi,
So I registered an account, but I have to request write permission by email to scipy-dev@scipy.org first. So could somebody give me write permission to the page
http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram2d.html
and maybe also to http://www.scipy.org/Cookbook/Matplotlib ?
Or otherwise could somebody add the example below for me?
Frank
--- import numpy as np, matplotlib.pyplot as plt
x = np.random.normal(3, 2, 1000) y = np.random.normal(3, 1, 1000)
yedges=xedges=[0,2,3,4,6]
H, yedges, xedges = np.histogram2d(y,x, bins=(yedges,xedges)) extent = [xedges[0], xedges[-1], yedges[-1], yedges[0]]
#If bin size is equal imshow can be used. It is fast and provides interpolation. #plt.imshow(H, extent=extent, interpolation='None', aspect='auto')
#To display variable bin size pcolar can be used X,Y = np.meshgrid(xedges, yedges) plt.pcolor(X, Y, H)
#If interpolation is needed in addition matplotlib provides the NonUniformImage: #http://matplotlib.org/examples/pylab_examples/image_nonuniform.html
plt.colorbar() plt.show()
On 2013-02-02 16:44, Sturla Molden wrote:
On 02.02.2013 10:53, Frank Breitling wrote:
Hi,
From the matplotlib developers it was pointed out, that there is a NonUniformImage which might be suite for representing interpolated variable bin size 2D histograms ( https://github.com/matplotlib/matplotlib/issues/1729#issuecomment-13014723 ). There even exists an example (http://matplotlib.org/examples/pylab_examples/image_nonuniform.html ) but it is very isolated and therefore not well known. It would be very useful to explain its usage or at least link to it in the histogram2d example at
http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram2d.html .
In addition a pcolor example (attached below) shouldn't be missing.
Even
though it is slow and can't do interpolation, it can at least do a correct representation for academic purposes.
Can anybody do that or would you like me to do that myself?
Frank Since it is at the top of your head, why don't you do it?
But it might be better for the SciPy Cookbook's matplotlib section than the NumPy docs. I'm not sure if they want matplotlib examples in the NumPy documentation (ask on the NumPy list before you waste your time on it).
http://www.scipy.org/Cookbook/Matplotlib
Sturla
_______________________________________________ SciPy-Dev mailing list SciPy-Dev@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-dev
_______________________________________________ SciPy-Dev mailing list SciPy-Dev@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-dev
_______________________________________________ SciPy-Dev mailing list SciPy-Dev@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-dev
_______________________________________________ SciPy-Dev mailing list SciPy-Dev@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-dev
_______________________________________________ SciPy-Dev mailing listSciPy-Dev@scipy.orghttp://mail.scipy.org/mailman/listinfo/scipy-dev
_______________________________________________ SciPy-Dev mailing list SciPy-Dev@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-dev
participants (4)
-
Frank Breitling
-
Ralf Gommers
-
Skipper Seabold
-
Sturla Molden