You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(3) |
Jun
|
Jul
|
Aug
(12) |
Sep
(12) |
Oct
(56) |
Nov
(65) |
Dec
(37) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(59) |
Feb
(78) |
Mar
(153) |
Apr
(205) |
May
(184) |
Jun
(123) |
Jul
(171) |
Aug
(156) |
Sep
(190) |
Oct
(120) |
Nov
(154) |
Dec
(223) |
| 2005 |
Jan
(184) |
Feb
(267) |
Mar
(214) |
Apr
(286) |
May
(320) |
Jun
(299) |
Jul
(348) |
Aug
(283) |
Sep
(355) |
Oct
(293) |
Nov
(232) |
Dec
(203) |
| 2006 |
Jan
(352) |
Feb
(358) |
Mar
(403) |
Apr
(313) |
May
(165) |
Jun
(281) |
Jul
(316) |
Aug
(228) |
Sep
(279) |
Oct
(243) |
Nov
(315) |
Dec
(345) |
| 2007 |
Jan
(260) |
Feb
(323) |
Mar
(340) |
Apr
(319) |
May
(290) |
Jun
(296) |
Jul
(221) |
Aug
(292) |
Sep
(242) |
Oct
(248) |
Nov
(242) |
Dec
(332) |
| 2008 |
Jan
(312) |
Feb
(359) |
Mar
(454) |
Apr
(287) |
May
(340) |
Jun
(450) |
Jul
(403) |
Aug
(324) |
Sep
(349) |
Oct
(385) |
Nov
(363) |
Dec
(437) |
| 2009 |
Jan
(500) |
Feb
(301) |
Mar
(409) |
Apr
(486) |
May
(545) |
Jun
(391) |
Jul
(518) |
Aug
(497) |
Sep
(492) |
Oct
(429) |
Nov
(357) |
Dec
(310) |
| 2010 |
Jan
(371) |
Feb
(657) |
Mar
(519) |
Apr
(432) |
May
(312) |
Jun
(416) |
Jul
(477) |
Aug
(386) |
Sep
(419) |
Oct
(435) |
Nov
(320) |
Dec
(202) |
| 2011 |
Jan
(321) |
Feb
(413) |
Mar
(299) |
Apr
(215) |
May
(284) |
Jun
(203) |
Jul
(207) |
Aug
(314) |
Sep
(321) |
Oct
(259) |
Nov
(347) |
Dec
(209) |
| 2012 |
Jan
(322) |
Feb
(414) |
Mar
(377) |
Apr
(179) |
May
(173) |
Jun
(234) |
Jul
(295) |
Aug
(239) |
Sep
(276) |
Oct
(355) |
Nov
(144) |
Dec
(108) |
| 2013 |
Jan
(170) |
Feb
(89) |
Mar
(204) |
Apr
(133) |
May
(142) |
Jun
(89) |
Jul
(160) |
Aug
(180) |
Sep
(69) |
Oct
(136) |
Nov
(83) |
Dec
(32) |
| 2014 |
Jan
(71) |
Feb
(90) |
Mar
(161) |
Apr
(117) |
May
(78) |
Jun
(94) |
Jul
(60) |
Aug
(83) |
Sep
(102) |
Oct
(132) |
Nov
(154) |
Dec
(96) |
| 2015 |
Jan
(45) |
Feb
(138) |
Mar
(176) |
Apr
(132) |
May
(119) |
Jun
(124) |
Jul
(77) |
Aug
(31) |
Sep
(34) |
Oct
(22) |
Nov
(23) |
Dec
(9) |
| 2016 |
Jan
(26) |
Feb
(17) |
Mar
(10) |
Apr
(8) |
May
(4) |
Jun
(8) |
Jul
(6) |
Aug
(5) |
Sep
(9) |
Oct
(4) |
Nov
|
Dec
|
| 2017 |
Jan
(5) |
Feb
(7) |
Mar
(1) |
Apr
(5) |
May
|
Jun
(3) |
Jul
(6) |
Aug
(1) |
Sep
|
Oct
(2) |
Nov
(1) |
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2025 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
1
(20) |
2
(21) |
3
(21) |
4
(14) |
5
(8) |
|
6
(12) |
7
(16) |
8
(27) |
9
(39) |
10
(19) |
11
(12) |
12
(3) |
|
13
(3) |
14
(18) |
15
(14) |
16
(6) |
17
(7) |
18
(19) |
19
(5) |
|
20
(8) |
21
(24) |
22
(42) |
23
(12) |
24
(11) |
25
(16) |
26
(2) |
|
27
(4) |
28
(10) |
|
|
|
|
|
|
From: Christoph G. <cg...@uc...> - 2011-02-02 23:59:46
|
On 2/2/2011 3:33 PM, Robert Abiad wrote: > Hello All, > > I'm very new to python, so bear with me. > > I'd like to use python to do my image processing, but I'm running into behavior that doesn't make > sense to me. I'm using Windows 7 Pro (64-bit) with 4 gigs of memory, python 2.6.6, and the newest > versions of ipython, pyfits, matplotlib (1.0.1), numpy (1.5.1), scipy. I'm loading in a fits file > that's 26 MB (~16 Mpixels). When I load my image in ImageJ, I can see memory usage go up by 50MB, > but when I try displaying the image using imshow(), my memory usage goes up by around 500MB, each > time. If I close the figure and replot it, imshow() crashes. I don't know if I'm doing something > wrong, or if it's a new or known bug. I tried the same thing on Linux and got the same result. > Here's a transcript. > > Welcome to pylab, a matplotlib-based Python environment. > For more information, type 'help(pylab)'. > > In [1]: import pyfits > > In [2]: from Tkinter import * > > In [3]: import tkFileDialog > > In [4]: image=pyfits.getdata(tkFileDialog.askopenfilename()) > > In [5]: imshow(image) > Out[5]:<matplotlib.image.AxesImage object at 0x03BCA170> > > In [6]: close() > > In [7]: imshow(image,origin='lower') > Out[7]:<matplotlib.image.AxesImage object at 0x0440E170> > > In [8]: close() > > In [9]: imshow(image[100:3600,100:3600],origin='lower') > Out[9]:<matplotlib.image.AxesImage object at 0x045D9FB0> > > In [10]: Exception in Tkinter callback > Traceback (most recent call last): > File "C:\app\Python2.6\lib\lib-tk\Tkinter.py", line 1410, in __call__ > return self.func(*args) > File "C:\app\Python2.6\lib\lib-tk\Tkinter.py", line 495, in callit > func(*args) > File "C:\app\Python2.6\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 263, in > idle_draw > self.draw() > File "C:\app\Python2.6\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 248, in draw > FigureCanvasAgg.draw(self) > File "C:\app\Python2.6\lib\site-packages\matplotlib\backends\backend_agg.py", line 394, in draw > self.figure.draw(self.renderer) > File "C:\app\Python2.6\lib\site-packages\matplotlib\artist.py", line 55, in draw_wrapper > draw(artist, renderer, *args, **kwargs) > File "C:\app\Python2.6\lib\site-packages\matplotlib\figure.py", line 798, in draw > func(*args) > File "C:\app\Python2.6\lib\site-packages\matplotlib\artist.py", line 55, in draw_wrapper > draw(artist, renderer, *args, **kwargs) > File "C:\app\Python2.6\lib\site-packages\matplotlib\axes.py", line 1946, in draw > a.draw(renderer) > File "C:\app\Python2.6\lib\site-packages\matplotlib\artist.py", line 55, in draw_wrapper > draw(artist, renderer, *args, **kwargs) > File "C:\app\Python2.6\lib\site-packages\matplotlib\image.py", line 354, in draw > im = self.make_image(renderer.get_image_magnification()) > File "C:\app\Python2.6\lib\site-packages\matplotlib\image.py", line 569, in make_image > transformed_viewLim) > File "C:\app\Python2.6\lib\site-packages\matplotlib\image.py", line 201, in _get_unsampled_image > x = self.to_rgba(self._A, self._alpha) > File "C:\app\Python2.6\lib\site-packages\matplotlib\cm.py", line 193, in to_rgba > x = self.norm(x) > File "C:\app\Python2.6\lib\site-packages\matplotlib\colors.py", line 820, in __call__ > result = (val-vmin) / (vmax-vmin) > File "C:\app\Python2.6\lib\site-packages\numpy\ma\core.py", line 3673, in __div__ > return divide(self, other) > File "C:\app\Python2.6\lib\site-packages\numpy\ma\core.py", line 1077, in __call__ > m |= filled(domain(da, db), True) > File "C:\app\Python2.6\lib\site-packages\numpy\ma\core.py", line 772, in __call__ > return umath.absolute(a) * self.tolerance>= umath.absolute(b) > MemoryError > > > Thanks for any help, > -robert > These are previous discussions on the issue: <http://www.mail-archive.com/mat...@li.../msg14727.html> <http://www.mail-archive.com/mat...@li.../msg19815.html> <http://www.mail-archive.com/mat...@li.../msg19614.html> Christoph |
|
From: Benjamin R. <ben...@ou...> - 2011-02-02 23:53:58
|
On Wed, Feb 2, 2011 at 5:33 PM, Robert Abiad <ab...@ss...> wrote: > Hello All, > > I'm very new to python, so bear with me. > > I'd like to use python to do my image processing, but I'm running into > behavior that doesn't make > sense to me. I'm using Windows 7 Pro (64-bit) with 4 gigs of memory, > python 2.6.6, and the newest > versions of ipython, pyfits, matplotlib (1.0.1), numpy (1.5.1), scipy. I'm > loading in a fits file > that's 26 MB (~16 Mpixels). When I load my image in ImageJ, I can see > memory usage go up by 50MB, > but when I try displaying the image using imshow(), my memory usage goes up > by around 500MB, each > time. If I close the figure and replot it, imshow() crashes. I don't know > if I'm doing something > wrong, or if it's a new or known bug. I tried the same thing on Linux and > got the same result. > Here's a transcript. > > Welcome to pylab, a matplotlib-based Python environment. > For more information, type 'help(pylab)'. > > In [1]: import pyfits > > In [2]: from Tkinter import * > > In [3]: import tkFileDialog > > In [4]: image=pyfits.getdata(tkFileDialog.askopenfilename()) > > In [5]: imshow(image) > Out[5]: <matplotlib.image.AxesImage object at 0x03BCA170> > > In [6]: close() > > In [7]: imshow(image,origin='lower') > Out[7]: <matplotlib.image.AxesImage object at 0x0440E170> > > In [8]: close() > > In [9]: imshow(image[100:3600,100:3600],origin='lower') > Out[9]: <matplotlib.image.AxesImage object at 0x045D9FB0> > > In [10]: Exception in Tkinter callback > Traceback (most recent call last): > File "C:\app\Python2.6\lib\lib-tk\Tkinter.py", line 1410, in __call__ > return self.func(*args) > File "C:\app\Python2.6\lib\lib-tk\Tkinter.py", line 495, in callit > func(*args) > File > "C:\app\Python2.6\lib\site-packages\matplotlib\backends\backend_tkagg.py", > line 263, in > idle_draw > self.draw() > File > "C:\app\Python2.6\lib\site-packages\matplotlib\backends\backend_tkagg.py", > line 248, in draw > FigureCanvasAgg.draw(self) > File > "C:\app\Python2.6\lib\site-packages\matplotlib\backends\backend_agg.py", > line 394, in draw > self.figure.draw(self.renderer) > File "C:\app\Python2.6\lib\site-packages\matplotlib\artist.py", line 55, > in draw_wrapper > draw(artist, renderer, *args, **kwargs) > File "C:\app\Python2.6\lib\site-packages\matplotlib\figure.py", line 798, > in draw > func(*args) > File "C:\app\Python2.6\lib\site-packages\matplotlib\artist.py", line 55, > in draw_wrapper > draw(artist, renderer, *args, **kwargs) > File "C:\app\Python2.6\lib\site-packages\matplotlib\axes.py", line 1946, > in draw > a.draw(renderer) > File "C:\app\Python2.6\lib\site-packages\matplotlib\artist.py", line 55, > in draw_wrapper > draw(artist, renderer, *args, **kwargs) > File "C:\app\Python2.6\lib\site-packages\matplotlib\image.py", line 354, > in draw > im = self.make_image(renderer.get_image_magnification()) > File "C:\app\Python2.6\lib\site-packages\matplotlib\image.py", line 569, > in make_image > transformed_viewLim) > File "C:\app\Python2.6\lib\site-packages\matplotlib\image.py", line 201, > in _get_unsampled_image > x = self.to_rgba(self._A, self._alpha) > File "C:\app\Python2.6\lib\site-packages\matplotlib\cm.py", line 193, in > to_rgba > x = self.norm(x) > File "C:\app\Python2.6\lib\site-packages\matplotlib\colors.py", line 820, > in __call__ > result = (val-vmin) / (vmax-vmin) > File "C:\app\Python2.6\lib\site-packages\numpy\ma\core.py", line 3673, in > __div__ > return divide(self, other) > File "C:\app\Python2.6\lib\site-packages\numpy\ma\core.py", line 1077, in > __call__ > m |= filled(domain(da, db), True) > File "C:\app\Python2.6\lib\site-packages\numpy\ma\core.py", line 772, in > __call__ > return umath.absolute(a) * self.tolerance >= umath.absolute(b) > MemoryError > > > Thanks for any help, > -robert > > This isn't new, but it isn't well understood either: http://www.mail-archive.com/mat...@li.../msg19614.html Unfortunately, that conversation went off-list, and never resulted in a bug report being filed. Could you please file a bug report on this? http://sourceforge.net/tracker/?group_id=80706 Thanks, Ben Root |
|
From: Robert A. <ab...@ss...> - 2011-02-02 23:32:10
|
Hello All,
I'm very new to python, so bear with me.
I'd like to use python to do my image processing, but I'm running into behavior that doesn't make
sense to me. I'm using Windows 7 Pro (64-bit) with 4 gigs of memory, python 2.6.6, and the newest
versions of ipython, pyfits, matplotlib (1.0.1), numpy (1.5.1), scipy. I'm loading in a fits file
that's 26 MB (~16 Mpixels). When I load my image in ImageJ, I can see memory usage go up by 50MB,
but when I try displaying the image using imshow(), my memory usage goes up by around 500MB, each
time. If I close the figure and replot it, imshow() crashes. I don't know if I'm doing something
wrong, or if it's a new or known bug. I tried the same thing on Linux and got the same result.
Here's a transcript.
Welcome to pylab, a matplotlib-based Python environment.
For more information, type 'help(pylab)'.
In [1]: import pyfits
In [2]: from Tkinter import *
In [3]: import tkFileDialog
In [4]: image=pyfits.getdata(tkFileDialog.askopenfilename())
In [5]: imshow(image)
Out[5]: <matplotlib.image.AxesImage object at 0x03BCA170>
In [6]: close()
In [7]: imshow(image,origin='lower')
Out[7]: <matplotlib.image.AxesImage object at 0x0440E170>
In [8]: close()
In [9]: imshow(image[100:3600,100:3600],origin='lower')
Out[9]: <matplotlib.image.AxesImage object at 0x045D9FB0>
In [10]: Exception in Tkinter callback
Traceback (most recent call last):
File "C:\app\Python2.6\lib\lib-tk\Tkinter.py", line 1410, in __call__
return self.func(*args)
File "C:\app\Python2.6\lib\lib-tk\Tkinter.py", line 495, in callit
func(*args)
File "C:\app\Python2.6\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 263, in
idle_draw
self.draw()
File "C:\app\Python2.6\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 248, in draw
FigureCanvasAgg.draw(self)
File "C:\app\Python2.6\lib\site-packages\matplotlib\backends\backend_agg.py", line 394, in draw
self.figure.draw(self.renderer)
File "C:\app\Python2.6\lib\site-packages\matplotlib\artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "C:\app\Python2.6\lib\site-packages\matplotlib\figure.py", line 798, in draw
func(*args)
File "C:\app\Python2.6\lib\site-packages\matplotlib\artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "C:\app\Python2.6\lib\site-packages\matplotlib\axes.py", line 1946, in draw
a.draw(renderer)
File "C:\app\Python2.6\lib\site-packages\matplotlib\artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "C:\app\Python2.6\lib\site-packages\matplotlib\image.py", line 354, in draw
im = self.make_image(renderer.get_image_magnification())
File "C:\app\Python2.6\lib\site-packages\matplotlib\image.py", line 569, in make_image
transformed_viewLim)
File "C:\app\Python2.6\lib\site-packages\matplotlib\image.py", line 201, in _get_unsampled_image
x = self.to_rgba(self._A, self._alpha)
File "C:\app\Python2.6\lib\site-packages\matplotlib\cm.py", line 193, in to_rgba
x = self.norm(x)
File "C:\app\Python2.6\lib\site-packages\matplotlib\colors.py", line 820, in __call__
result = (val-vmin) / (vmax-vmin)
File "C:\app\Python2.6\lib\site-packages\numpy\ma\core.py", line 3673, in __div__
return divide(self, other)
File "C:\app\Python2.6\lib\site-packages\numpy\ma\core.py", line 1077, in __call__
m |= filled(domain(da, db), True)
File "C:\app\Python2.6\lib\site-packages\numpy\ma\core.py", line 772, in __call__
return umath.absolute(a) * self.tolerance >= umath.absolute(b)
MemoryError
Thanks for any help,
-robert
|
|
From: Fernando C. <fer...@gm...> - 2011-02-02 22:49:13
|
Just for the record I am sending Sebastian's message to the list
---------- Forwarded message ----------
From: Sebastian Voigt <>
Date: 2 February 2011 17:23
Subject: Re: [Matplotlib-users] Qt sizeHint
To: Fernando Cosso <>
Hi Fernando,
I changed your MplCanvas class. The sizeHint function is not needed, if this
produces the desired baviour:
class MplCanvas(FigureCanvas):
def __init__(self):
self.fig = Figure(linewidth=0)
FigureCanvas.__init__(self, self.fig)
self._text = r'$\alpha > \beta$'
self._g = self.fig.suptitle(self._text)
self.renderer = self.get_renderer()
bbox = self._g.get_window_extent(self.renderer)
self.setFixedHeight(bbox.height)
self.setFixedWidth(bbox.width)
Ahoi,
Sebastian
Am 02.02.2011 22:41, schrieb Fernando Cosso:
Dear List
I am a really newbie in Python, Matlibplot and Qt but I am still making huge
progress in my project.
I am now stuck trying to make a custom widget for Qt Desginer using
matplotlib to display a Latex formula. I would like the Latex label to
provide Qt with the correct size, with enough space to fit the text and
nothing else.
I know from Qt that I should re implement the sizeHint method but I don't
know how to get the minimum size.
I tried the get_window_extent() but I need a renderer for that.
Any idea?
This is what I have so far
from PyQt4 import QtGui
from PyQt4 import QtCore
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as
FigureCanvas
from matplotlib.figure import Figure
class MplCanvas(FigureCanvas):
def __init__(self):
self.fig = Figure(linewidth=0)
FigureCanvas.__init__(self, self.fig)
self._text = r'$\alpha > \beta$'
self._g = self.fig.suptitle(self._text)
FigureCanvas.setSizePolicy(self,
QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
def sizeHint(self):
print(self._g.get_window_extent())
return QtCore.QSize(something1, something2)
class Plot2D(QtGui.QWidget):
def __init__(self, parent = None):
QtGui.QWidget.__init__(self, parent)
self.canvas = MplCanvas()
self.vbl = QtGui.QVBoxLayout()
self.vbl.addWidget(self.canvas)
self.setLayout(self.vbl)
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
widget = Plot2D()
widget.show()
sys.exit(app.exec_())
Anything is appreciated!
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Matplotlib-users mailing
lis...@li...://lists.sourceforge.net/lists/listinfo/matplotlib-users
|
|
From: Jim K. <ji...@gm...> - 2011-02-02 20:17:39
|
'pick_event' fires when I pick on either the marker or the line segment of a Line2D object. But if I change the drawstyle to use steps (steps-pre, steps-post, steps-mid), picking on the line segment is broken. It still seems to think the line is linear. This leads to very strange behavior where picking on a line gives no feedback (e.g. a tooltip), but picking on a blank part of the graph does. Do I need to write my own custom picker function or is this an oversight in the code? Thanks, Jim |
|
From: Benjamin R. <ben...@ou...> - 2011-02-02 19:49:25
|
On Wed, Feb 2, 2011 at 1:16 PM, Patton Bradford <pat...@at...>wrote: > Just trying to get familiar with mplot3d's functions, and I've run into a > problem with plot_wireframe that I'm having problems running down (or > duplicating, for that matter). I'm trying to generate plots of some wavelet > functions, so I need to plot values against time and scale. I've generated > three numpy arrays: X (time), Y (scale) (generated these using meshgrid), > and Z (values, a rather sparse matrix). I verified that all of these are > the same shape (7x100) by fetching the 'shape' attribute from X,Y,Z. > However, when I call plot_wireframe(), I get this error: > > Exception in Tkinter callback > Traceback (most recent call last): > File "C:\Python26\lib\lib-tk\Tkinter.py", line 1410, in __call__ > return self.func(*args) > File > "C:\Python26\lib\site-packages\matplotlib\backends\backend_tkagg.py", line > 212, in resize > self.show() > File > "C:\Python26\lib\site-packages\matplotlib\backends\backend_tkagg.py", line > 215, in draw > FigureCanvasAgg.draw(self) > File "C:\Python26\lib\site-packages\matplotlib\backends\backend_agg.py", > line 314, in draw > self.figure.draw(self.renderer) > File "C:\Python26\Lib\site-packages\matplotlib\artist.py", line 46, in > draw_wrapper > draw(artist, renderer, *args, **kwargs) > File "C:\Python26\lib\site-packages\matplotlib\figure.py", line 773, in > draw > for a in self.axes: a.draw(renderer) > File "C:\Python26\lib\site-packages\mpl_toolkits\mplot3d\axes3d.py", line > 135, in draw > for col in self.collections] > File "C:\Python26\Lib\site-packages\mpl_toolkits\mplot3d\art3d.py", line > 163, in do_3d_projection > self._segments3d] > File "C:\Python26\lib\site-packages\mpl_toolkits\mplot3d\proj3d.py", line > 211, in proj_trans_points > return proj_transform(xs, ys, zs, M) > File "C:\Python26\lib\site-packages\mpl_toolkits\mplot3d\proj3d.py", line > 193, in proj_transform > vec = vec_pad_ones(xs, ys, zs) > File "C:\Python26\lib\site-packages\mpl_toolkits\mplot3d\proj3d.py", line > 184, in vec_pad_ones > vec = np.array([xs,ys,zs,np.ones((len(xs)))]) > ValueError: setting an array element with a sequence. > > Any suggestions as to what the problem might be? As I said, I'm having > problems duplicating it in "toy" programs. > > Thanks in advance. > > /s/ > Pat > > Pat, plot_wireframe (and plot_surface as well) can be very tricky to use. Typically, the way to go about it is through a parametric approach. For example, if I wanted a wireframe of a sphere, I would create two arrays of u and v (azimuth and elevation) and use that to create x, y, z (assuming constant r). The key to making these surfaces work is that the order of the array elements is very important because the plotting function uses this information to link up neighboring points. Could you please post a self-contained version of your code that demonstrates the problem? Ben Root |
|
From: Patton B. <pat...@at...> - 2011-02-02 19:16:10
|
Just trying to get familiar with mplot3d's functions, and I've run into a problem with plot_wireframe that I'm having problems running down (or duplicating, for that matter). I'm trying to generate plots of some wavelet functions, so I need to plot values against time and scale. I've generated three numpy arrays: X (time), Y (scale) (generated these using meshgrid), and Z (values, a rather sparse matrix). I verified that all of these are the same shape (7x100) by fetching the 'shape' attribute from X,Y,Z. However, when I call plot_wireframe(), I get this error: Exception in Tkinter callback Traceback (most recent call last): File "C:\Python26\lib\lib-tk\Tkinter.py", line 1410, in __call__ return self.func(*args) File "C:\Python26\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 212, in resize self.show() File "C:\Python26\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 215, in draw FigureCanvasAgg.draw(self) File "C:\Python26\lib\site-packages\matplotlib\backends\backend_agg.py", line 314, in draw self.figure.draw(self.renderer) File "C:\Python26\Lib\site-packages\matplotlib\artist.py", line 46, in draw_wrapper draw(artist, renderer, *args, **kwargs) File "C:\Python26\lib\site-packages\matplotlib\figure.py", line 773, in draw for a in self.axes: a.draw(renderer) File "C:\Python26\lib\site-packages\mpl_toolkits\mplot3d\axes3d.py", line 135, in draw for col in self.collections] File "C:\Python26\Lib\site-packages\mpl_toolkits\mplot3d\art3d.py", line 163, in do_3d_projection self._segments3d] File "C:\Python26\lib\site-packages\mpl_toolkits\mplot3d\proj3d.py", line 211, in proj_trans_points return proj_transform(xs, ys, zs, M) File "C:\Python26\lib\site-packages\mpl_toolkits\mplot3d\proj3d.py", line 193, in proj_transform vec = vec_pad_ones(xs, ys, zs) File "C:\Python26\lib\site-packages\mpl_toolkits\mplot3d\proj3d.py", line 184, in vec_pad_ones vec = np.array([xs,ys,zs,np.ones((len(xs)))]) ValueError: setting an array element with a sequence. Any suggestions as to what the problem might be? As I said, I'm having problems duplicating it in "toy" programs. Thanks in advance. /s/ Pat |
|
From: Francois M. <fm...@ne...> - 2011-02-02 15:10:45
|
Hello, I use matplolib by the mathematical system Sage in order to plot a function. The Sage code calls matplotlib and uses its options : The Sage command is plot (sin, x, -5, 5) I add labels par axes_labels or remove axes by : plot (sin(x), x, -5, 5, axes_label = ['x', 'y']) plot (sin(x), x, -5, 5, axes=false) French users (and maybe others) uses arrows and not lines for axes. I'm looking for a plot (sin(x), x, -5, 5, axes="arrows") Is there a pretty way to get these arrows. The result of this code isn't so fine. length, width and color don't match. plot (sin(x), x, -5, 5, axes=false) + arrow ((-5,0),(5,0)) + arrow ((0,-1),(0,1)) What options do you propose ? I don't find relevant answers in the archive. F. from France. |
|
From: Daniel M. <dan...@go...> - 2011-02-02 12:45:31
|
Hi, I'd very much vote for such a feature, too. It's absolutely not
foolproof currently the way it is :(
What I find weird, too, is that while everthing fits on the canvas for PDF
output, the left side is cropped for PNG.
´
Best regards,
Daniel
2011/2/1 Paul Anton Letnes wrote:
>
> On 10. juni 2009, at 14.53, John Hunter wrote:
>
> > On Wed, Jun 10, 2009 at 1:58 AM, Paul Anton
> > Letnes wrote:
> >
> >>> This _must_ be a bug. Consider the following:
> >>> ##############
> >>> import matplotlib
> >
> > No it is not a bug -- mpl is doing what you tell it to do. Consider
> >
> >>>> figure()
> >>>> subplot(111)
> >>>> plot([1,2,3])
> >>>> xlabel('hi mom', fontsize=100)
> >
> > Each command has precise meaning -- the fig creates a figure using the
> > default size, the subplot occupies a fraction of that figure according
> > to the default ratios in the subplots_adjust parameters, and the
> > xlabel makes a label at an indicated physical size. You may not be
> > explicitly setting those sizes, but they are all defined via defaults
> > in the matplotlibrc. We try and make mpl do what you tell it to do,
> > not to try and out-smart you and do what we think you are telling it
> > to do.
> >
> > Now I definitely support the idea that we should have a *feature* to
> > auto-adjust the subplots_adjust params and fontsizes so that it "just
> > works" more often. But this should be an optional feature so the user
> > who wants to express their intent clearly will not constantly be
> > stymied by mpl adjusting the sizes. Michael Droettboom has worked on
> > it and it is a difficult problem to get right.
> >
> > JDH
>
> I don't mean to bother people with this question again, but has anyone
> implemented this auto-adjust feature that John was talking about? It would
> be nice not having to adjust matplotlib.rcParams['figure.subplot.left'] (and
> friends) in every plot script, or alternatively, through a clever hierarchy
> of matplotlibrc files.
>
> By the way: kudos to matplotlib in every other respect!
>
> Cheers
> Paul
>
|
|
From: Francesco M. <fra...@go...> - 2011-02-02 09:48:18
|
Hi Paul, 2011/2/1 Paul Ivanov <piv...@gm...> > I'm not sure what you're hoping to see, but you should either use > xerr with xuplims, or yerr with uplims. > Thank you for the reply. As usually I checked everything except the correct one. By the way, if one uses (by error) yerr and xuplims/xlolims or xerr and uplims/lolims, no error bar shows up. Is this a bug or a feature? Cheers, Fra |
|
From: Jeremy C. <jlc...@gm...> - 2011-02-02 03:18:51
|
On Tue, Feb 1, 2011 at 6:31 PM, Eric Firing <ef...@ha...> wrote: > On 02/01/2011 02:18 PM, Benjamin Root wrote: >> On Tue, Feb 1, 2011 at 6:05 PM, Jeremy Conlin <jlc...@gm... >> <mailto:jlc...@gm...>> wrote: >> >> On Tue, Feb 1, 2011 at 5:00 PM, Benjamin Root <ben...@ou... >> <mailto:ben...@ou...>> wrote: >> > >> > >> > On Tue, Feb 1, 2011 at 5:48 PM, Jeremy Conlin <jlc...@gm... >> <mailto:jlc...@gm...>> wrote: >> >> >> >> I'm trying to create a custom colormap used with pcolormesh, but the >> >> results seem inconsistent to me. I want the following colors >> >> >> >> -3 < x <= -2 ----- Black >> >> -2 < x <= -1 ----- Blue >> >> -1 < x <= 0 ----- Yellow >> >> 0 < x <= 1 ----- Green >> >> 1 < x <= inf ----- Red >> >> >> >> A minimal example is copied below. I have a 2-D array that >> looks like: >> >> >> >> -1, 6, 2.5 >> >> 1.3, -2, 4/3 >> >> 2.5, 6, 0 >> >> >> >> I want to get a pcolormesh that looks like >> >> >> >> R R Y >> >> R K R >> >> B R R >> >> >> >> But instead I get: >> >> >> >> Y R B >> >> Y K Y >> >> K R Y >> >> >> >> I recognize that the pcolormesh is plotted "upside-down" from >> how the >> >> matrix is printed. I apparently don't understand how to use a >> custom >> >> colormap. I have tried to follow the example here: >> >> >> >> http://matplotlib.sourceforge.net/examples/api/colorbar_only.html >> >> >> >> but haven't been too successful. It seems like there is a >> >> normalization going on that I can't seem to track down. Can anyone >> >> see what is wrong? >> >> >> >> Thanks, >> >> Jeremy >> >> >> >> >> >> import numpy >> >> import matplotlib.pyplot as pyplot >> >> import matplotlib.colors >> >> >> >> C = numpy.array([[-1,6,2.5],[4/3., -2, >> 4/3.],[2.5,6,0.0]],dtype=float) >> >> >> >> cMap = matplotlib.colors.ListedColormap(['k', 'b', 'y', 'g', 'r']) >> >> Bounds = [-3.0, -2.0, -1.0, 0.0, 1.0, numpy.inf] >> >> >> >> # Plot >> >> Fig = pyplot.figure() >> >> pyplot.pcolormesh(C, cmap=cMap) >> >> >> > >> > Have you given imshow() a try? The pcolor() and family are >> really meant for >> > more general domain specifications. imshow() is about as basic >> as one can >> > get for producing an image that shows the colors for particular >> values. >> > matshow() also does something similar and doesn't interpolate between >> > points. >> > >> > I don't know if it would fix your problem, but it should be a >> good start. >> >> I just tried both imshow and matshow and they gave the same output, >> but the plot was rotated -90º. I don't care so much about how it is >> oriented, but I do care about consistency, i.e. -1 should be plotted >> as blue, but is instead black. I could also accept -1 as yellow since >> -1 is on the boundary. pcolor, imshow, and matshow all show the same >> inconsistency. >> >> Jeremy >> >> >> I think I just figured out what is wrong. In your code, you create a >> ListedColormap, but you don't assign a Norm object. So, when you call >> pcolor or whatever, it will use the default norm using the range of >> input values. I see you created a list of boundaries called Bounds, but >> you don't do anything with it. >> >> I believe you want to first make a BoundaryNorm object using Bounds and >> pass that object to the ListedColormap using the norm keyword. > > Not to the ListedColormap, but to the imshow or whatever. Here is an > example of BoundaryNorm: > > http://matplotlib.sourceforge.net/examples/pylab_examples/image_masked.html > > And here is another, using a BoundaryNorm with a ListedColormap: > > http://matplotlib.sourceforge.net/examples/pylab_examples/multicolored_line.html > > (It is the first of the two line plots.) > > Note that you need to instantiate it with the number of colors in your > colormap. > > Eric Thanks everyone for there help. You were right, it was a normalization problem. I added a normalization and now I get what I want (see final code below). Jeremy import numpy import matplotlib.pyplot as pyplot import matplotlib.colors C = numpy.array([[-1,6,2.5],[4/3., -2, 4/3.],[2.5,6,0.0]],dtype=float) cMap = matplotlib.colors.ListedColormap(['k', 'b', 'y', 'g', 'r']) Bounds = [-3.0, -2.0, -1.0, 0.0, 1.0, numpy.inf] Norm = matplotlib.colors.BoundaryNorm(Bounds, cMap.N) # Plot Fig = pyplot.figure() pyplot.pcolormesh(C-1E-15, cmap=cMap, norm=Norm) |
|
From: Denzel Li <den...@gm...> - 2011-02-02 02:51:57
|
Hi Paul:
Thank you for you quick response.
I am using pythonxy 2.6.5.6. The matplotlib version is:
import matplotlib
print matplotlib.__version__
1.0.0
Do you mean the problem is fixed in matplotlib version 1.0.1? I will upgrade
it and see how it works.
Your suggestion of ylim(3.5, -0.5) does work.
Thanks a lot.
Best,
Denzel
On Tue, Feb 1, 2011 at 4:42 PM, Paul Ivanov <piv...@gm...> wrote:
> Denzel Li, on 2011-02-01 15:34, wrote:
> > I had this problem but could not find the answer online. I will be highly
> > appreciating if anyone can point me some direction on this problem.
> > I installed pythonxy and used matplotlib through ipython. I used matshow
> to
> > draw a matrix and then set ticklables. This lead to the shown rows having
> > uneven height. The following shows my problem:
> > ----------------------
> > import numpy
> > M=randn(4,6)
> > matshow(M)
> > -----------------------
> > This works fine and is shown in fig1.png. However, after I set the
> yticks:
> > ------------------------
> > yticks(arange(4), ('1','2','3','4'))
> > ---------------------------
> > The rows of the matrix drawn have uneven height. Please see fig2.png.
>
> Hi Denzel,
>
> what version of matplotlib are you using? I am unable to
> reproduce on fairly recent checkout of svn trunk, so it may be an
> issue that was recently fixed.
>
> one workaround would be to set the ylim after the call to yticks,
> like this:
>
> plt.ylim(3.5, -0.5)
>
> best,
> --
> Paul Ivanov
> 314 address only used for lists, off-list direct email at:
> http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
>
> iEYEARECAAYFAk1Ifi0ACgkQe+cmRQ8+KPft6wCfRbaTT87V+S56AxwMIXK9HPvA
> E8IAn1tl+ssa5puGREWoHlnAb0V3G4yv
> =n6jX
> -----END PGP SIGNATURE-----
>
>
> ------------------------------------------------------------------------------
> Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
> Finally, a world-class log management solution at an even better
> price-free!
> Download using promo code Free_Logger_4_Dev2Dev. Offer expires
> February 28th, so secure your free ArcSight Logger TODAY!
> http://p.sf.net/sfu/arcsight-sfd2d
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
|
|
From: Paul I. <piv...@gm...> - 2011-02-02 01:37:35
|
Paul Ivanov, on 2011-02-01 17:14, wrote: > Kris Kuhlman, on 2011-02-01 18:03, wrote: > > I am trying to plot a large number of locations that need to be labeled. > > Often the locations are quite clustered and the resulting text is > > unreadable. I have been looking through the API and examples on the > > matplotlib web page, and I don't see a straightforward way to plot text > > labels, preventing them from overlapping. There is no easy answer to the > > problem, since locating the labels so they are close to the point you want > > to label, and not overlapping is a sort of optimization problem, I guess. > > > > Using annotate(), the location and alignment of the text can be fixed, but > > you don't know the size of the resulting box until after draw() is called. > > Once draw is called, you can inquire what the bounding box for a label is, > > and then check to see if it overlaps with other labels, but this is an > > iterative process, and draw() can be quite slow to call repeatedly. > > > > I guess unless you use a fixed-width font (possible, but not optimal), you > > just don't know how big the labels will be, and therefore where they will > > extend to, and then how they should be avoided. This involves coming up > > with some sort of accounting system for the location and size of each text > > box, outside of the matplotlib API, and seems sub-optimal. > > > > Has anybody dealt with this problem and come up with an elegant or efficient > > solution? > > Hi Kris, > > unfortunately, there isn't a turn-key solution implemented for > this at the moment, but this would be something very useful and > something I've been wanting to see in matplotlib, but never had a > strong enough need to implement myself. > > Take a look here for the type of machinery that could be used to > implement such functionality: > > http://matplotlib.sourceforge.net/faq/howto_faq.html#automatically-make-room-for-tick-labels I should add that the overlaps and count_overlaps methods of mpl.transforms.Bbox could be used for some sort of iterative solution, as you can get the bounding box using a = plt.annotate("Foo",(1,2)) bbox = a.get_window_extent() Also, depeding on the number of labels and the need for reproducibility of plots, you can just make the labels draggable, and move them around using the mouse a.draggable() best, -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 |
|
From: Eric F. <ef...@ha...> - 2011-02-02 01:31:27
|
On 02/01/2011 02:18 PM, Benjamin Root wrote: > On Tue, Feb 1, 2011 at 6:05 PM, Jeremy Conlin <jlc...@gm... > <mailto:jlc...@gm...>> wrote: > > On Tue, Feb 1, 2011 at 5:00 PM, Benjamin Root <ben...@ou... > <mailto:ben...@ou...>> wrote: > > > > > > On Tue, Feb 1, 2011 at 5:48 PM, Jeremy Conlin <jlc...@gm... > <mailto:jlc...@gm...>> wrote: > >> > >> I'm trying to create a custom colormap used with pcolormesh, but the > >> results seem inconsistent to me. I want the following colors > >> > >> -3 < x <= -2 ----- Black > >> -2 < x <= -1 ----- Blue > >> -1 < x <= 0 ----- Yellow > >> 0 < x <= 1 ----- Green > >> 1 < x <= inf ----- Red > >> > >> A minimal example is copied below. I have a 2-D array that > looks like: > >> > >> -1, 6, 2.5 > >> 1.3, -2, 4/3 > >> 2.5, 6, 0 > >> > >> I want to get a pcolormesh that looks like > >> > >> R R Y > >> R K R > >> B R R > >> > >> But instead I get: > >> > >> Y R B > >> Y K Y > >> K R Y > >> > >> I recognize that the pcolormesh is plotted "upside-down" from > how the > >> matrix is printed. I apparently don't understand how to use a > custom > >> colormap. I have tried to follow the example here: > >> > >> http://matplotlib.sourceforge.net/examples/api/colorbar_only.html > >> > >> but haven't been too successful. It seems like there is a > >> normalization going on that I can't seem to track down. Can anyone > >> see what is wrong? > >> > >> Thanks, > >> Jeremy > >> > >> > >> import numpy > >> import matplotlib.pyplot as pyplot > >> import matplotlib.colors > >> > >> C = numpy.array([[-1,6,2.5],[4/3., -2, > 4/3.],[2.5,6,0.0]],dtype=float) > >> > >> cMap = matplotlib.colors.ListedColormap(['k', 'b', 'y', 'g', 'r']) > >> Bounds = [-3.0, -2.0, -1.0, 0.0, 1.0, numpy.inf] > >> > >> # Plot > >> Fig = pyplot.figure() > >> pyplot.pcolormesh(C, cmap=cMap) > >> > > > > Have you given imshow() a try? The pcolor() and family are > really meant for > > more general domain specifications. imshow() is about as basic > as one can > > get for producing an image that shows the colors for particular > values. > > matshow() also does something similar and doesn't interpolate between > > points. > > > > I don't know if it would fix your problem, but it should be a > good start. > > I just tried both imshow and matshow and they gave the same output, > but the plot was rotated -90º. I don't care so much about how it is > oriented, but I do care about consistency, i.e. -1 should be plotted > as blue, but is instead black. I could also accept -1 as yellow since > -1 is on the boundary. pcolor, imshow, and matshow all show the same > inconsistency. > > Jeremy > > > I think I just figured out what is wrong. In your code, you create a > ListedColormap, but you don't assign a Norm object. So, when you call > pcolor or whatever, it will use the default norm using the range of > input values. I see you created a list of boundaries called Bounds, but > you don't do anything with it. > > I believe you want to first make a BoundaryNorm object using Bounds and > pass that object to the ListedColormap using the norm keyword. Not to the ListedColormap, but to the imshow or whatever. Here is an example of BoundaryNorm: http://matplotlib.sourceforge.net/examples/pylab_examples/image_masked.html And here is another, using a BoundaryNorm with a ListedColormap: http://matplotlib.sourceforge.net/examples/pylab_examples/multicolored_line.html (It is the first of the two line plots.) Note that you need to instantiate it with the number of colors in your colormap. Eric > > That should fix it. > > Ben Root |
|
From: Paul I. <piv...@gm...> - 2011-02-02 01:14:49
|
Kris Kuhlman, on 2011-02-01 18:03, wrote: > I am trying to plot a large number of locations that need to be labeled. > Often the locations are quite clustered and the resulting text is > unreadable. I have been looking through the API and examples on the > matplotlib web page, and I don't see a straightforward way to plot text > labels, preventing them from overlapping. There is no easy answer to the > problem, since locating the labels so they are close to the point you want > to label, and not overlapping is a sort of optimization problem, I guess. > > Using annotate(), the location and alignment of the text can be fixed, but > you don't know the size of the resulting box until after draw() is called. > Once draw is called, you can inquire what the bounding box for a label is, > and then check to see if it overlaps with other labels, but this is an > iterative process, and draw() can be quite slow to call repeatedly. > > I guess unless you use a fixed-width font (possible, but not optimal), you > just don't know how big the labels will be, and therefore where they will > extend to, and then how they should be avoided. This involves coming up > with some sort of accounting system for the location and size of each text > box, outside of the matplotlib API, and seems sub-optimal. > > Has anybody dealt with this problem and come up with an elegant or efficient > solution? Hi Kris, unfortunately, there isn't a turn-key solution implemented for this at the moment, but this would be something very useful and something I've been wanting to see in matplotlib, but never had a strong enough need to implement myself. Take a look here for the type of machinery that could be used to implement such functionality: http://matplotlib.sourceforge.net/faq/howto_faq.html#automatically-make-room-for-tick-labels best, -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 |
|
From: Kris K. <kri...@gm...> - 2011-02-02 01:03:59
|
I am trying to plot a large number of locations that need to be labeled. Often the locations are quite clustered and the resulting text is unreadable. I have been looking through the API and examples on the matplotlib web page, and I don't see a straightforward way to plot text labels, preventing them from overlapping. There is no easy answer to the problem, since locating the labels so they are close to the point you want to label, and not overlapping is a sort of optimization problem, I guess. Using annotate(), the location and alignment of the text can be fixed, but you don't know the size of the resulting box until after draw() is called. Once draw is called, you can inquire what the bounding box for a label is, and then check to see if it overlaps with other labels, but this is an iterative process, and draw() can be quite slow to call repeatedly. I guess unless you use a fixed-width font (possible, but not optimal), you just don't know how big the labels will be, and therefore where they will extend to, and then how they should be avoided. This involves coming up with some sort of accounting system for the location and size of each text box, outside of the matplotlib API, and seems sub-optimal. Has anybody dealt with this problem and come up with an elegant or efficient solution? Kris |
|
From: Paul I. <piv...@gm...> - 2011-02-02 00:33:25
|
Jeremy Conlin, on 2011-02-01 16:48, wrote: > I'm trying to create a custom colormap used with pcolormesh, but the > results seem inconsistent to me. I want the following colors > > -3 < x <= -2 ----- Black > -2 < x <= -1 ----- Blue > -1 < x <= 0 ----- Yellow > 0 < x <= 1 ----- Green > 1 < x <= inf ----- Red > > A minimal example is copied below. I have a 2-D array that looks like: > > -1, 6, 2.5 > 1.3, -2, 4/3 > 2.5, 6, 0 > > I want to get a pcolormesh that looks like > > R R Y > R K R > B R R > > But instead I get: > > Y R B > Y K Y > K R Y > > I recognize that the pcolormesh is plotted "upside-down" from how the > matrix is printed. I apparently don't understand how to use a custom > colormap. I have tried to follow the example here: > > http://matplotlib.sourceforge.net/examples/api/colorbar_only.html > > but haven't been too successful. It seems like there is a > normalization going on that I can't seem to track down. Can anyone > see what is wrong? > > Thanks, > Jeremy > > > import numpy > import matplotlib.pyplot as pyplot > import matplotlib.colors > > C = numpy.array([[-1,6,2.5],[4/3., -2, 4/3.],[2.5,6,0.0]],dtype=float) > > cMap = matplotlib.colors.ListedColormap(['k', 'b', 'y', 'g', 'r']) > Bounds = [-3.0, -2.0, -1.0, 0.0, 1.0, numpy.inf] > > # Plot > Fig = pyplot.figure() > pyplot.pcolormesh(C, cmap=cMap) Hi Jeremy, you're right, matplotlib expects colors to be in the range 0-1. I've added the appropriate normalization below. I also had to subtract a small number from C to adjust for your specification of the desired intervals being closed on the upper bound, because the default makes lower bound closed. In other words, the default is to treat the bounds as -3 <= x < -2 for black, in your case, instead of -3 < x <= -2 as you wanted it. # R R Y # R K R # B R R n = mpl.colors.normalize(-3,2) pyplot.pcolormesh(C-(1e-15), cmap=cMap,norm=n) |
|
From: Benjamin R. <ben...@ou...> - 2011-02-02 00:19:28
|
On Tue, Feb 1, 2011 at 6:05 PM, Jeremy Conlin <jlc...@gm...> wrote: > On Tue, Feb 1, 2011 at 5:00 PM, Benjamin Root <ben...@ou...> wrote: > > > > > > On Tue, Feb 1, 2011 at 5:48 PM, Jeremy Conlin <jlc...@gm...> > wrote: > >> > >> I'm trying to create a custom colormap used with pcolormesh, but the > >> results seem inconsistent to me. I want the following colors > >> > >> -3 < x <= -2 ----- Black > >> -2 < x <= -1 ----- Blue > >> -1 < x <= 0 ----- Yellow > >> 0 < x <= 1 ----- Green > >> 1 < x <= inf ----- Red > >> > >> A minimal example is copied below. I have a 2-D array that looks like: > >> > >> -1, 6, 2.5 > >> 1.3, -2, 4/3 > >> 2.5, 6, 0 > >> > >> I want to get a pcolormesh that looks like > >> > >> R R Y > >> R K R > >> B R R > >> > >> But instead I get: > >> > >> Y R B > >> Y K Y > >> K R Y > >> > >> I recognize that the pcolormesh is plotted "upside-down" from how the > >> matrix is printed. I apparently don't understand how to use a custom > >> colormap. I have tried to follow the example here: > >> > >> http://matplotlib.sourceforge.net/examples/api/colorbar_only.html > >> > >> but haven't been too successful. It seems like there is a > >> normalization going on that I can't seem to track down. Can anyone > >> see what is wrong? > >> > >> Thanks, > >> Jeremy > >> > >> > >> import numpy > >> import matplotlib.pyplot as pyplot > >> import matplotlib.colors > >> > >> C = numpy.array([[-1,6,2.5],[4/3., -2, 4/3.],[2.5,6,0.0]],dtype=float) > >> > >> cMap = matplotlib.colors.ListedColormap(['k', 'b', 'y', 'g', > 'r']) > >> Bounds = [-3.0, -2.0, -1.0, 0.0, 1.0, numpy.inf] > >> > >> # Plot > >> Fig = pyplot.figure() > >> pyplot.pcolormesh(C, cmap=cMap) > >> > > > > Have you given imshow() a try? The pcolor() and family are really meant > for > > more general domain specifications. imshow() is about as basic as one > can > > get for producing an image that shows the colors for particular values. > > matshow() also does something similar and doesn't interpolate between > > points. > > > > I don't know if it would fix your problem, but it should be a good start. > > I just tried both imshow and matshow and they gave the same output, > but the plot was rotated -90º. I don't care so much about how it is > oriented, but I do care about consistency, i.e. -1 should be plotted > as blue, but is instead black. I could also accept -1 as yellow since > -1 is on the boundary. pcolor, imshow, and matshow all show the same > inconsistency. > > Jeremy > I think I just figured out what is wrong. In your code, you create a ListedColormap, but you don't assign a Norm object. So, when you call pcolor or whatever, it will use the default norm using the range of input values. I see you created a list of boundaries called Bounds, but you don't do anything with it. I believe you want to first make a BoundaryNorm object using Bounds and pass that object to the ListedColormap using the norm keyword. That should fix it. Ben Root |
|
From: Jeremy C. <jlc...@gm...> - 2011-02-02 00:05:37
|
On Tue, Feb 1, 2011 at 5:00 PM, Benjamin Root <ben...@ou...> wrote: > > > On Tue, Feb 1, 2011 at 5:48 PM, Jeremy Conlin <jlc...@gm...> wrote: >> >> I'm trying to create a custom colormap used with pcolormesh, but the >> results seem inconsistent to me. I want the following colors >> >> -3 < x <= -2 ----- Black >> -2 < x <= -1 ----- Blue >> -1 < x <= 0 ----- Yellow >> 0 < x <= 1 ----- Green >> 1 < x <= inf ----- Red >> >> A minimal example is copied below. I have a 2-D array that looks like: >> >> -1, 6, 2.5 >> 1.3, -2, 4/3 >> 2.5, 6, 0 >> >> I want to get a pcolormesh that looks like >> >> R R Y >> R K R >> B R R >> >> But instead I get: >> >> Y R B >> Y K Y >> K R Y >> >> I recognize that the pcolormesh is plotted "upside-down" from how the >> matrix is printed. I apparently don't understand how to use a custom >> colormap. I have tried to follow the example here: >> >> http://matplotlib.sourceforge.net/examples/api/colorbar_only.html >> >> but haven't been too successful. It seems like there is a >> normalization going on that I can't seem to track down. Can anyone >> see what is wrong? >> >> Thanks, >> Jeremy >> >> >> import numpy >> import matplotlib.pyplot as pyplot >> import matplotlib.colors >> >> C = numpy.array([[-1,6,2.5],[4/3., -2, 4/3.],[2.5,6,0.0]],dtype=float) >> >> cMap = matplotlib.colors.ListedColormap(['k', 'b', 'y', 'g', 'r']) >> Bounds = [-3.0, -2.0, -1.0, 0.0, 1.0, numpy.inf] >> >> # Plot >> Fig = pyplot.figure() >> pyplot.pcolormesh(C, cmap=cMap) >> > > Have you given imshow() a try? The pcolor() and family are really meant for > more general domain specifications. imshow() is about as basic as one can > get for producing an image that shows the colors for particular values. > matshow() also does something similar and doesn't interpolate between > points. > > I don't know if it would fix your problem, but it should be a good start. I just tried both imshow and matshow and they gave the same output, but the plot was rotated -90º. I don't care so much about how it is oriented, but I do care about consistency, i.e. -1 should be plotted as blue, but is instead black. I could also accept -1 as yellow since -1 is on the boundary. pcolor, imshow, and matshow all show the same inconsistency. Jeremy |
|
From: Benjamin R. <ben...@ou...> - 2011-02-02 00:01:14
|
On Tue, Feb 1, 2011 at 5:48 PM, Jeremy Conlin <jlc...@gm...> wrote: > I'm trying to create a custom colormap used with pcolormesh, but the > results seem inconsistent to me. I want the following colors > > -3 < x <= -2 ----- Black > -2 < x <= -1 ----- Blue > -1 < x <= 0 ----- Yellow > 0 < x <= 1 ----- Green > 1 < x <= inf ----- Red > > A minimal example is copied below. I have a 2-D array that looks like: > > -1, 6, 2.5 > 1.3, -2, 4/3 > 2.5, 6, 0 > > I want to get a pcolormesh that looks like > > R R Y > R K R > B R R > > But instead I get: > > Y R B > Y K Y > K R Y > > I recognize that the pcolormesh is plotted "upside-down" from how the > matrix is printed. I apparently don't understand how to use a custom > colormap. I have tried to follow the example here: > > http://matplotlib.sourceforge.net/examples/api/colorbar_only.html > > but haven't been too successful. It seems like there is a > normalization going on that I can't seem to track down. Can anyone > see what is wrong? > > Thanks, > Jeremy > > > import numpy > import matplotlib.pyplot as pyplot > import matplotlib.colors > > C = numpy.array([[-1,6,2.5],[4/3., -2, 4/3.],[2.5,6,0.0]],dtype=float) > > cMap = matplotlib.colors.ListedColormap(['k', 'b', 'y', 'g', 'r']) > Bounds = [-3.0, -2.0, -1.0, 0.0, 1.0, numpy.inf] > > # Plot > Fig = pyplot.figure() > pyplot.pcolormesh(C, cmap=cMap) > > Have you given imshow() a try? The pcolor() and family are really meant for more general domain specifications. imshow() is about as basic as one can get for producing an image that shows the colors for particular values. matshow() also does something similar and doesn't interpolate between points. I don't know if it would fix your problem, but it should be a good start. Ben Root |