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
(16) |
2
(31) |
3
(17) |
4
(18) |
5
(7) |
6
(5) |
7
(16) |
8
(9) |
9
(19) |
10
(18) |
11
(17) |
12
(7) |
13
(6) |
14
(15) |
15
(16) |
16
(15) |
17
(19) |
18
(27) |
19
(10) |
20
(5) |
21
(5) |
22
(19) |
23
(7) |
24
(11) |
25
(19) |
26
(1) |
27
(36) |
28
(37) |
29
(28) |
30
(36) |
|
|
|
Thanks, that works like a charm. final bonus question: How can i individually set the point of view/zoom level for the different 3d subplots? Currently, when i rotate/zoom (with the mouse) in one subplot, the changes are applied on all 3d subplots. Thanks again, q On Mon, Sep 28, 2009 at 11:52:08PM -0400, Jae-Joon Lee wrote: > Try below instead of Axes3D. Obviously, "131" is the geometry > parameter for subplot command. You don't need to add "ax" to "fig" > since Axes3D do that by itself. > > from matplotlib.axes import subplot_class_factory > Subplot3D = subplot_class_factory(Axes3D) > > ax = Subplot3D(fig, 131) > > This will show you the title also. However, the 3d axes will occupy > smaller area than the area of the subplot. > > Regards, > > -JJ > > > On Mon, Sep 28, 2009 at 6:23 PM, <qu...@gm...> wrote: > > Greetings, > > > > I would like to plot to make a figure with 3 subplots > > of the form (221) to (223): > > - each subplot should show a bar3d plot of a matrix > > - each subplot should have it's own title > > > > The problems: > > a) I don't see (nor did i find something) how i can > > use subplots combined with bar3d (from the mpl_toolkits.mplot3d) > > package. > > > > b) I don't manage to give the 3d bar plot a title. In the attached > > code you will see that a title is set, but it does not show > > up in the figure > > > > Could someone please help me out with these problems? > > > > Thanks, > > q > > > > --------------------- > > > > The code for the basic plot of the matrix: > > > > > > from mpl_toolkits.mplot3d import Axes3D > > import matplotlib.pyplot as plt > > from matplotlib.ticker import FixedFormatter, LinearLocator, FixedLocator > > from numpy import * > > > > psi=1/sqrt(2)*array([1, 0, 0, 1]) > > rho=outer(psi,psi) > > > > fig = plt.figure() > > > > ax = Axes3D(fig) > > > > elements = (len(rho) * len(rho)) > > xpos, ypos = meshgrid(array(range(len(rho)))+0.25, array(range(len(rho)))+0.25) > > > > xpos = xpos.flatten() > > ypos = ypos.flatten() > > zpos = zeros(elements) > > > > dx = 0.5 * ones_like(zpos) > > dy = dx.copy() > > dz = absolute(rho.flatten()) > > > > ax.set_title('absolute') > > > > ax.bar3d(xpos, ypos, zpos, dx, dy, dz, color='#F8F800') > > > > plt.show() > > > > > > > > ------------------------------------------------------------------------------ > > Come build with us! The BlackBerry® Developer Conference in SF, CA > > is the only developer event you need to attend this year. Jumpstart your > > developing skills, take BlackBerry mobile applications to market and stay > > ahead of the curve. Join us from November 9-12, 2009. Register now! > > http://p.sf.net/sfu/devconf > > _______________________________________________ > > Matplotlib-users mailing list > > Mat...@li... > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > -- The king who needs to remind his people of his rank, is no king. To gain that which is worth having, it may be necessary to lose everything else.
Hi everybody, I try to play with "sharex" feature. Then, I have been guided to the class "Grouper" of module cbook: http://matplotlib.sourceforge.net/api/cbook_api.html So I tried the following example: ############################## from matplotlib.cbook import * g = Grouper() g.join('a', 'b') ############################## I obtain: Traceback (most recent call last): File "test_grouper.py", line 4, in <module> g.join('a', 'b') File ".../matplotlib/cbook.py", line 1118, in join set_a = mapping.setdefault(ref(a), [ref(a)]) TypeError: cannot create weak reference to 'str' object What is the problem? Thanks in advance, Julien -- python -c "print ''.join([chr(154 - ord(c)) for c in '*9(9&(18%.\ 9&1+,\'Z4(55l4('])" "When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong." (first law of AC Clarke)
Hey everybody, thank you for your answers. I use matplotlib from qt4 now. What I do is creating a widget in a gui and using this for plotting. The plot is to refreshed by clicking on a button. This works perfectly fine, until I start adding a colorbar to the plot. When I add the colorbar and replot the whole thing, the plot doesnt fill up the area of the widget in the gui, but roughly 80% of the horizontal extent of the last plot. So when I replot in the axes, my plot shrinks around 20% horizontally every time I click on the button. I found out how to delete the old colorbar, but where do I tell matplotlib to plot into the whole extent of the plot? This is the widget i instantiate in my gui: class MyMplCanvas(FigureCanvas): def __init__(self, parent=None, width = 10, height = 12, dpi = 100, sharex = None, sharey = None): self.fig = Figure(figsize = (width, height), dpi=dpi, facecolor = '#FFFFFF') self.ax = self.fig.add_subplot(111, sharex = sharex, sharey = sharey) self.fig.subplots_adjust(left=0.1, bottom=0.15, right=0.9, top=0.9) self.xtitle="x [a.u.]" self.ytitle="y [a.u.]" self.PlotTitle = "" self.grid_status = True self.xaxis_style = 'linear' self.yaxis_style = 'linear' self.format_labels() self.ax.hold(False) ....... And this would be the code I call for plotting: elif self.ui.radioButton_theta.isChecked() : data = N.vstack([ self.data_theta[self.nx/2:,:,self.filepos], self.data_theta[:self.nx/2,:,self.filepos]] ) title_str = 'Theta T.%03d' % self.filepos self.ui.widget.canvas.ax.collections = [] plt = self.ui.widget.canvas.ax.contourf(data) self.ui.widget.canvas.fig.colorbar(plt) self.ui.widget.canvas.PlotTitle = title_str self.ui.widget.canvas.print_figure('plot') I thought the call self.ui.widget.canvas.ax.collections = [] clears the axes. Any ideas? Cheers, Ralph Eric Firing wrote: > Matthias Michler wrote: >> Hi Ralph, >> >> I don't think there exists a function like the line-'set_data'-method for >> collections, which are generated by 'contour'. This particular method of >> lines only changes the data but leave anything else unchanged. >> I attached an easy approach of updating a contour plot (simply deleting old >> collections), but I'm not sure that this is the best solution. > > I don't think you area gaining anything at all by manually deleting the > collections. Better to just clear the axes, or clear the figure, and > make a fresh plot. > > Eric > > >> Kind regards, >> Matthias >> >> On Monday 28 September 2009 13:52:42 Ralph Kube wrote: >>> Hi, >>> is there a way to update a contour plot? I need to display a series of >>> contour plots from a directory with data files and want to view them >>> consecutively, preferrably without building a gui for it. Is there an >>> easy way out? >>> >>> Cheers, Ralph
After experimenting with colormaps for a while, I was able to make both discrete (piecewise-constant) and continuous (piecewise-linear) colormaps work. Although colormaps can be created directly using LinearSegmentedColormap from the matplotlib.colors package, this is a tedious and error-prone process. So, I compiled a set of three interface functions. (I wrote two of these myself, and got one from the SciPy website). The two functions that I wrote permit one to define a discrete (piecewise-constant) and continuous (piecewise-linear) colormap directly via a sequence of colors and a set of thresholds specified as lists. Each color may be specified either via an RGB tuple or via an English color name known to webcolors.name_to_rgb. I'm going to submit all of this to the matplotlib developers forums in the hopes of getting it incorporated into matplotlib. -- View this message in context: http://www.nabble.com/new-interface-functions-for-LinearSegmentedColormap-tp25657187p25657187.html Sent from the matplotlib - users mailing list archive at Nabble.com.
felix meyenhofer wrote: > The package is installed. In the interpreter the 'import matplotlib' > does not throw an error. On the other hand I tried to use matplotlib > in a python script and here the very same command provokes the > following error message: how are you running that script? I supect you are getting a different python. try: $ python TheNameOfTheScript that should get you the same python as you get typig "python" If you run the script directly: $ ./TheNameOfTheScript it will use the #! line at the top to tell it where to find python. If that line says" #!/usr/bin/python you'll probably get a different one. the usual convention is: #!/usr/bin/env python which should get you the same one that you get when you start python at the command line. a few things to try to test all this: $ which python $ python -c "import sys; print sys.path" $ python -c "import sys; print sys.executable" putting import sys" and "print sys.path" or "print sys.executable" at the top of your troublesome script. HTH, -Chris > Traceback (most recent call last): > File "./account3.py", line 13, in <module> > import matplotlib > ImportError: No module named matplotlib > > I would be greatful for any help/explanaiton. > Cheers, > Felix > > $ uname -aDarwin mac-screening-1 9.8.0 Darwin Kernel Version 9.8.0: > Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228154~1/RELEASE_I386 i386 > > $ python > Python 2.5.4 (r254:67917, Dec 23 2008, 14:57:27) > [GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin > > $ python -c 'import matplotlib; print matplotlib.__version__, > matplotlib.__file__' > 0.99.0 /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ > site-packages/matplotlib/__init__.pyc > > The Package was downloaded from the link: > http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-0.99.1/matplotlib-0.99.1.1-py2.5-macosx10.5.dmg/download > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry® Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9-12, 2009. Register now! > http://p.sf.net/sfu/devconf > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chr...@no...
Jae-Joon Lee wrote: > > Hmm, I'm afraid that this only works if you use preview mode. I > haven't tested, but I guess it will fail without it. Check if > rcParams["text.latex.preview"]==True. > Hm, I don't know about mpl's mathtext mode, but I'm actually always working in usetex mode. Unfortunately, even so, "text.latex.preview" does not exist in rcParams for me. However,... : I think the following behaviour is definitely buggy! Please try the following one at a time, in ion() mode (or just see sequence of png's produced). None of these succeeds in getting the desired alignment. from matplotlib import rc figure(1) clf() plot([0,0],[1,1]) rc('text', usetex=True) text(xlim()[1],.96,r'$r^2$~~~\mbox{}',horizontalalignment='right') savefig('t10.png') rc('text', usetex=False) show() savefig('t20.png') text(xlim()[1],.97,r'$r^2$~~~\mbox{}',horizontalalignment='right') savefig('t30.png') rc('text', usetex=True) show() savefig('t40.png') -- View this message in context: http://www.nabble.com/trailing-space-in-text-string-stripped%2C-making-it-impossible-to-right-pad-my-text-tp25639703p25656912.html Sent from the matplotlib - users mailing list archive at Nabble.com.
Try below instead of Axes3D. Obviously, "131" is the geometry parameter for subplot command. You don't need to add "ax" to "fig" since Axes3D do that by itself. from matplotlib.axes import subplot_class_factory Subplot3D = subplot_class_factory(Axes3D) ax = Subplot3D(fig, 131) This will show you the title also. However, the 3d axes will occupy smaller area than the area of the subplot. Regards, -JJ On Mon, Sep 28, 2009 at 6:23 PM, <qu...@gm...> wrote: > Greetings, > > I would like to plot to make a figure with 3 subplots > of the form (221) to (223): > - each subplot should show a bar3d plot of a matrix > - each subplot should have it's own title > > The problems: > a) I don't see (nor did i find something) how i can > use subplots combined with bar3d (from the mpl_toolkits.mplot3d) > package. > > b) I don't manage to give the 3d bar plot a title. In the attached > code you will see that a title is set, but it does not show > up in the figure > > Could someone please help me out with these problems? > > Thanks, > q > > --------------------- > > The code for the basic plot of the matrix: > > > from mpl_toolkits.mplot3d import Axes3D > import matplotlib.pyplot as plt > from matplotlib.ticker import FixedFormatter, LinearLocator, FixedLocator > from numpy import * > > psi=1/sqrt(2)*array([1, 0, 0, 1]) > rho=outer(psi,psi) > > fig = plt.figure() > > ax = Axes3D(fig) > > elements = (len(rho) * len(rho)) > xpos, ypos = meshgrid(array(range(len(rho)))+0.25, array(range(len(rho)))+0.25) > > xpos = xpos.flatten() > ypos = ypos.flatten() > zpos = zeros(elements) > > dx = 0.5 * ones_like(zpos) > dy = dx.copy() > dz = absolute(rho.flatten()) > > ax.set_title('absolute') > > ax.bar3d(xpos, ypos, zpos, dx, dy, dz, color='#F8F800') > > plt.show() > > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry® Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9-12, 2009. Register now! > http://p.sf.net/sfu/devconf > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >
The exception will go away if you explicitly use np.array as below. box = np.array([[self.x, self.y1], [self.x, self.y2]]) However, note that Mike's example has x-center at 0. -JJ On Mon, Sep 28, 2009 at 6:41 PM, Uri Laserson <las...@mi...> wrote: > Hi Mike, > > This is definitely on the right track. Thanks a lot for writing it > out. When I change the view limits, indeed the width stays constant > while the height gets rescaled. However, when I try to change to a > logarithmic axis, I get the following errors. Again, excuse my > ignorance, but I am not sure where exactly the offense is and how to > fix it. > > > In [57]: ax.set_xscale('log') > > In [58]: plt.draw() > ERROR: An unexpected error occurred while tokenizing input > The following traceback may be corrupted or invalid > The error message is: ('EOF in multi-line statement', (568, 0)) > > ERROR: An unexpected error occurred while tokenizing input > The following traceback may be corrupted or invalid > The error message is: ('EOF in multi-line statement', (568, 0)) > > ERROR: An unexpected error occurred while tokenizing input > The following traceback may be corrupted or invalid > The error message is: ('EOF in multi-line statement', (568, 0)) > > --------------------------------------------------------------------------- > TypeError Traceback (most recent call last) > > /Users/laserson/Desktop/<ipython console> in <module>() > > /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/pyplot.pyc > in draw() > 348 def draw(): > 349 'redraw the current figure' > --> 350 get_current_fig_manager().canvas.draw() > 351 > 352 @docstring.copy_dedent(Figure.savefig) > > /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/backends/backend_tkagg.pyc > in draw(self) > 213 > 214 def draw(self): > --> 215 FigureCanvasAgg.draw(self) > 216 tkagg.blit(self._tkphoto, self.renderer._renderer, colormode=2) > 217 self._master.update_idletasks() > > /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/backends/backend_agg.pyc > in draw(self) > 376 > 377 self.renderer = self.get_renderer() > --> 378 self.figure.draw(self.renderer) > 379 > 380 def get_renderer(self): > > /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/artist.pyc > in draw_wrapper(artist, renderer, *kl) > 53 def draw_wrapper(artist, renderer, *kl): > 54 before(artist, renderer) > ---> 55 draw(artist, renderer, *kl) > 56 after(artist, renderer) > 57 > > /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/figure.pyc > in draw(self, renderer) > 770 > 771 # render the axes > --> 772 for a in self.axes: a.draw(renderer) > 773 > 774 # render the figure text > > /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/artist.pyc > in draw_wrapper(artist, renderer, *kl) > 53 def draw_wrapper(artist, renderer, *kl): > 54 before(artist, renderer) > ---> 55 draw(artist, renderer, *kl) > 56 after(artist, renderer) > 57 > > /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/axes.pyc > in draw(self, renderer, inframe) > 1743 > 1744 for zorder, i, a in dsu: > -> 1745 a.draw(renderer) > 1746 > 1747 renderer.close_group('axes') > > /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/artist.pyc > in draw_wrapper(artist, renderer, *kl) > 53 def draw_wrapper(artist, renderer, *kl): > 54 before(artist, renderer) > ---> 55 draw(artist, renderer, *kl) > 56 after(artist, renderer) > 57 > > /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/patches.pyc > in draw(self, renderer) > 353 > 354 path = self.get_path() > --> 355 transform = self.get_transform() > 356 tpath = transform.transform_path_non_affine(path) > 357 affine = transform.get_affine() > > /Users/laserson/Desktop/testMyPatch.py in get_transform(self) > 22 box = [[self.x, self.y1], > 23 [self.x, self.y2]] > ---> 24 box = self.axes.transData.transform(box) > 25 > 26 # Get the width as a fraction of the axes width > > /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/transforms.pyc > in transform(self, points) > 1893 def transform(self, points): > 1894 return self._b.transform( > -> 1895 self._a.transform(points)) > 1896 transform.__doc__ = Transform.transform.__doc__ > 1897 > > /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/transforms.pyc > in transform(self, points) > 1721 x_points = x.transform(points)[:, 0:1] > 1722 else: > -> 1723 x_points = x.transform(points[:, 0]) > 1724 x_points = x_points.reshape((len(x_points), 1)) > 1725 > > TypeError: list indices must be integers > > > > On Mon, Sep 28, 2009 at 16:56, Michael Droettboom <md...@st...> wrote: >> Is the attached sort of what you want? It defines a custom rectangle by (x, >> w, y1, y2) and overrides the get_transform of the patch to update itself at >> draw time. >> >> Mike >> >> Uri Laserson wrote: >>> >>> On Mon, Sep 28, 2009 at 16:03, Michael Droettboom <md...@st...> wrote: >>> >>>> >>>> If I understand correctly, the top and bottom of the box are in data >>>> coordinates, the x-center of the box is in data coordinates, only the >>>> width >>>> of the box is in axes coordinates. Is that correct? If so, a >>>> >>> >>> That's exactly correct. >>> >>> >>>> >>>> PolyCollection won't be able to do this (directly), since that would >>>> require >>>> both the width and height to be in axes coordinates. >>>> >>> >>> In principle, could you use a blended tranform for that? Eitherway, I >>> don't think it would work, because the patch objects would be drawn to >>> specific Axes coords. If the scale is changed (e.g, by switching to >>> log scale), then what would prompt the Axes coords to be recalculated? >>> I was thinking earlier that I could compose the transData and >>> transAxes.inverse transforms to recalculate where the new Axes coord >>> should be, but Mike thought this approach would fail (though I'm still >>> not exactly sure why, no doubt because of my own ignorance). >>> >>> Uri >>> >>> >>>> >>>> Mike >>>> >>>> Eric Firing wrote: >>>> >>>>> >>>>> Uri Laserson wrote: >>>>> >>>>> >>>>>> >>>>>> Is it possible to specify a path object that will use different >>>>>> transforms for different vertices? >>>>>> >>>>>> This is again related to plotting a box whose height is specified by >>>>>> data coords, but whose width is a constant in axes coords regardless >>>>>> of scale (so linear and log x-scales would produce a box of the same >>>>>> width). >>>>>> >>>>>> Ideally, I would draw a path like this: >>>>>> 1. the center of the box would be located at x and bottom and top >>>>>> would be y1, y2, all in data coords >>>>>> 2. I would move to (x,y1) at the bottom-center of the box. >>>>>> 3. The x value would now need to be converted to Axes coords, possibly >>>>>> by applying transData + transAxes.inverted >>>>>> 4. I would want to draw a line to (x-0.1, y1) where x is now in axes >>>>>> coords and y is still in data coords. Then up, then right, then down, >>>>>> and then close the polygon. >>>>>> >>>>>> How do I implement this? >>>>>> >>>>>> >>>>> >>>>> I must be missing something, because I still don't see why you can't do >>>>> all this very simply by using a PolyCollection, with the vertices in >>>>> axes >>>>> coordinates and the offset in data coordinates. >>>>> >>>>> Eric >>>>> >>>>> >>>>> >>>>>> >>>>>> As I mentioned before, a blended transform would allow me to make the >>>>>> moves i am interested in. However, a change of scale would change the >>>>>> correspondence between data and axes coords, so the axes transform >>>>>> part of the blended axes would have to be recomputed everytime the >>>>>> scale changes based on where the (x,y1) point lands in the axes. Is >>>>>> this correct? >>>>>> >>>>>> Any suggestions are welcome...thanks! >>>>>> >>>>>> Uri >>>>>> >>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>>> ------------------------------------------------------------------------------ >>>>> Come build with us! The BlackBerry® Developer Conference in SF, CA >>>>> is the only developer event you need to attend this year. Jumpstart your >>>>> developing skills, take BlackBerry mobile applications to market and >>>>> stay >>>>> ahead of the curve. Join us from November 9-12, 2009. Register >>>>> now! >>>>> http://p.sf.net/sfu/devconf >>>>> _______________________________________________ >>>>> Matplotlib-users mailing list >>>>> Mat...@li... >>>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>>>> >>>>> >>>> >>>> -- >>>> Michael Droettboom >>>> Science Software Branch >>>> Operations and Engineering Division >>>> Space Telescope Science Institute >>>> Operated by AURA for NASA >>>> >>>> >>>> >>> >>> >>> >>> >> >> -- >> Michael Droettboom >> Science Software Branch >> Operations and Engineering Division >> Space Telescope Science Institute >> Operated by AURA for NASA >> >> >> import numpy as np >> import matplotlib.pyplot as plt >> import matplotlib.patches as mpatches >> import matplotlib.transforms as mtransforms >> import matplotlib.path as mpath >> >> class MyBox(mpatches.Patch): >> >> def __init__(self, x, w, y1, y2, **kwargs): >> self.x = x >> self.w = w >> self.y1 = y1 >> self.y2 = y2 >> mpatches.Patch.__init__(self, **kwargs) >> >> def get_path(self): >> return mpath.Path.unit_rectangle() >> >> def get_transform(self): >> >> # Transform the data-relative values >> box = [[self.x, self.y1], >> [self.x, self.y2]] >> box = self.axes.transData.transform(box) >> >> # Get the width as a fraction of the axes width >> w = self.w * self.axes.bbox.width / 2.0 >> >> # Add it to the data-transformed coordinates >> box[0][0] -= w >> box[1][0] += w >> >> return mtransforms.BboxTransformTo(mtransforms.Bbox(box)) >> >> fig = plt.figure() >> ax = fig.add_subplot(111) >> patch = MyBox(0, 0.1, 0.5, 1.5) >> ax.add_patch(patch) >> ax.set_xlim((-1, 1)) >> ax.set_ylim((0, 2)) >> >> plt.show() >> >> > > > > -- > Uri Laserson > PhD Candidate, Biomedical Engineering > Harvard Medical School (Genetics) > Massachusetts Institute of Technology (Mathematics) > phone +1 917 742 8019 > las...@mi... > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry® Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9-12, 2009. Register now! > http://p.sf.net/sfu/devconf > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >
> > Could you possibly explain exactly what is going on and how this > structurally differs from the approach that Mike posted? > > In Mike's code, he uses BboxTransformTo using the box he created in > display coords. So this takes a unit square and spits out the box > that I specify when I instantiate the custom patch (using data coords > for x and y and axes coords for w). What is called to actually draw > the box (i.e., when I execute plt.draw())? Is that get_path()? So > basically, whenever MPL wants to draw a patch, does it always call > get_path() and then runs it through whatever is returned from > get_transform() to get the final shape in display coords? Your understanding is basically right. When plt.draw(or any equivalent) is called, the draw methods of each artists are called. And the draw method of the Patch class, in general, calls the get_path and get_transform, while details can be different. > > So how does this relate to the strategy that you are advocating? Is > _update_patch_transform somehow a synonym for what I described in the > paragraph above? I don't know where that fits into the picture. > Yes, for the Rectangle class, its get_transform method returns a combined transform of patch_transform + default_artist_transform, where the patch_transform is used to transform the unit rectangle to the data coordinate. So, the basic idea is very similar to Mike's implementation, while Mike's should be more efficient as it transforms the unit rectangle directly to the canvas coordinate. > It may be useful to add something to the "Working With Tranformations" > section or the "Transformation Tutorial" about what is minimally > necessary to override for a custom patch. I have been playing around > with MPL for some time now (albeit I don't have much computer > visualization/graphics experience) and still have only a fuzzy idea of > what order things are called in and what the overall > strategy/structure of the system is like. > Well, right now, I guess the source code is your best tutor (which was and still is for me). You may start with the mpatches.Patch that Mike's MyBox inherit from. And any contribution will be greatly appreciated! -JJ > Uri > >> >> -JJ >> >>> Uri >>> >>>> >>>> Mike >>>> >>>> Eric Firing wrote: >>>>> >>>>> Uri Laserson wrote: >>>>> >>>>>> >>>>>> Is it possible to specify a path object that will use different >>>>>> transforms for different vertices? >>>>>> >>>>>> This is again related to plotting a box whose height is specified by >>>>>> data coords, but whose width is a constant in axes coords regardless >>>>>> of scale (so linear and log x-scales would produce a box of the same >>>>>> width). >>>>>> >>>>>> Ideally, I would draw a path like this: >>>>>> 1. the center of the box would be located at x and bottom and top >>>>>> would be y1, y2, all in data coords >>>>>> 2. I would move to (x,y1) at the bottom-center of the box. >>>>>> 3. The x value would now need to be converted to Axes coords, possibly >>>>>> by applying transData + transAxes.inverted >>>>>> 4. I would want to draw a line to (x-0.1, y1) where x is now in axes >>>>>> coords and y is still in data coords. Then up, then right, then down, >>>>>> and then close the polygon. >>>>>> >>>>>> How do I implement this? >>>>>> >>>>> >>>>> I must be missing something, because I still don't see why you can't do >>>>> all this very simply by using a PolyCollection, with the vertices in axes >>>>> coordinates and the offset in data coordinates. >>>>> >>>>> Eric >>>>> >>>>> >>>>>> >>>>>> As I mentioned before, a blended transform would allow me to make the >>>>>> moves i am interested in. However, a change of scale would change the >>>>>> correspondence between data and axes coords, so the axes transform >>>>>> part of the blended axes would have to be recomputed everytime the >>>>>> scale changes based on where the (x,y1) point lands in the axes. Is >>>>>> this correct? >>>>>> >>>>>> Any suggestions are welcome...thanks! >>>>>> >>>>>> Uri >>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>>> >>>>> ------------------------------------------------------------------------------ >>>>> Come build with us! The BlackBerry® Developer Conference in SF, CA >>>>> is the only developer event you need to attend this year. Jumpstart your >>>>> developing skills, take BlackBerry mobile applications to market and stay >>>>> ahead of the curve. Join us from November 9-12, 2009. Register now! >>>>> http://p.sf.net/sfu/devconf >>>>> _______________________________________________ >>>>> Matplotlib-users mailing list >>>>> Mat...@li... >>>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>>>> >>>> >>>> -- >>>> Michael Droettboom >>>> Science Software Branch >>>> Operations and Engineering Division >>>> Space Telescope Science Institute >>>> Operated by AURA for NASA >>>> >>>> >>> >>> >>> >>> -- >>> Uri Laserson >>> PhD Candidate, Biomedical Engineering >>> Harvard Medical School (Genetics) >>> Massachusetts Institute of Technology (Mathematics) >>> phone +1 917 742 8019 >>> las...@mi... >>> >>> ------------------------------------------------------------------------------ >>> Come build with us! The BlackBerry® Developer Conference in SF, CA >>> is the only developer event you need to attend this year. Jumpstart your >>> developing skills, take BlackBerry mobile applications to market and stay >>> ahead of the curve. Join us from November 9-12, 2009. Register now! >>> http://p.sf.net/sfu/devconf >>> _______________________________________________ >>> Matplotlib-users mailing list >>> Mat...@li... >>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>> >> > > > > -- > Uri Laserson > PhD Candidate, Biomedical Engineering > Harvard Medical School (Genetics) > Massachusetts Institute of Technology (Mathematics) > phone +1 917 742 8019 > las...@mi... >
I'm not sure its possible right now to do subplots with 3D. As for the title, I cannot either put titles on any 3D graphs... 2009年9月28日 <qu...@gm...> > Greetings, > > I would like to plot to make a figure with 3 subplots > of the form (221) to (223): > - each subplot should show a bar3d plot of a matrix > - each subplot should have it's own title > > The problems: > a) I don't see (nor did i find something) how i can > use subplots combined with bar3d (from the mpl_toolkits.mplot3d) > package. > > b) I don't manage to give the 3d bar plot a title. In the attached > code you will see that a title is set, but it does not show > up in the figure > > Could someone please help me out with these problems? > > Thanks, > q > > --------------------- > > The code for the basic plot of the matrix: > > > from mpl_toolkits.mplot3d import Axes3D > import matplotlib.pyplot as plt > from matplotlib.ticker import FixedFormatter, LinearLocator, FixedLocator > from numpy import * > > psi=1/sqrt(2)*array([1, 0, 0, 1]) > rho=outer(psi,psi) > > fig = plt.figure() > > ax = Axes3D(fig) > > elements = (len(rho) * len(rho)) > xpos, ypos = meshgrid(array(range(len(rho)))+0.25, > array(range(len(rho)))+0.25) > > xpos = xpos.flatten() > ypos = ypos.flatten() > zpos = zeros(elements) > > dx = 0.5 * ones_like(zpos) > dy = dx.copy() > dz = absolute(rho.flatten()) > > ax.set_title('absolute') > > ax.bar3d(xpos, ypos, zpos, dx, dy, dz, color='#F8F800') > > plt.show() > > > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry® Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9-12, 2009. Register now! > http://p.sf.net/sfu/devconf > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >
Hello, my problem is described very quickly: The package is installed. In the interpreter the 'import matplotlib' does not throw an error. On the other hand I tried to use matplotlib in a python script and here the very same command provokes the following error message: Traceback (most recent call last): File "./account3.py", line 13, in <module> import matplotlib ImportError: No module named matplotlib I would be greatful for any help/explanaiton. Cheers, Felix $ uname -aDarwin mac-screening-1 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228154~1/RELEASE_I386 i386 $ python Python 2.5.4 (r254:67917, Dec 23 2008, 14:57:27) [GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin $ python -c 'import matplotlib; print matplotlib.__version__, matplotlib.__file__' 0.99.0 /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ site-packages/matplotlib/__init__.pyc The Package was downloaded from the link: http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-0.99.1/matplotlib-0.99.1.1-py2.5-macosx10.5.dmg/download
On Mon, Sep 28, 2009 at 16:53, Jae-Joon Lee <lee...@gm...> wrote: > I personally think that a box, whose height has a physical meaning (in > data coordinate) while its width does not, is not a good > representation of your data. A vertical line or something like > errorbar seems to be more suitable to me. I agree, and if you're a fan of Edward Tufte, then you definitely agree. In his book, he takes the simple Tukey-style boxplot and turns it into a 1-dimension object, in line with the type of data it's representing. However, I still want to implement something that's a bit more traditional, which is why I wanted to pick an arbitrary width for the boxes that stay invariant regardless of the scale that I use. > As Mike has explained, the transform trick (blended or not) won't > work. The width and y-center will be always transformed with the same > transform, which is not what you want. I think you need to create a > custom patch class for this to work. One option seems to subclass the > Rectangle class and overide the _update_patch_transform method. The > patch transform is used to transform a unit rectangle to a rectangle > in data coordinate (or whatever coordinate the patch uses), i.e., you > need to calculate the coordinate of the box in the data coordinate(or > whatever coordinate the patch uses). Could you possibly explain exactly what is going on and how this structurally differs from the approach that Mike posted? In Mike's code, he uses BboxTransformTo using the box he created in display coords. So this takes a unit square and spits out the box that I specify when I instantiate the custom patch (using data coords for x and y and axes coords for w). What is called to actually draw the box (i.e., when I execute plt.draw())? Is that get_path()? So basically, whenever MPL wants to draw a patch, does it always call get_path() and then runs it through whatever is returned from get_transform() to get the final shape in display coords? So how does this relate to the strategy that you are advocating? Is _update_patch_transform somehow a synonym for what I described in the paragraph above? I don't know where that fits into the picture. It may be useful to add something to the "Working With Tranformations" section or the "Transformation Tutorial" about what is minimally necessary to override for a custom patch. I have been playing around with MPL for some time now (albeit I don't have much computer visualization/graphics experience) and still have only a fuzzy idea of what order things are called in and what the overall strategy/structure of the system is like. Uri > > -JJ > >> Uri >> >>> >>> Mike >>> >>> Eric Firing wrote: >>>> >>>> Uri Laserson wrote: >>>> >>>>> >>>>> Is it possible to specify a path object that will use different >>>>> transforms for different vertices? >>>>> >>>>> This is again related to plotting a box whose height is specified by >>>>> data coords, but whose width is a constant in axes coords regardless >>>>> of scale (so linear and log x-scales would produce a box of the same >>>>> width). >>>>> >>>>> Ideally, I would draw a path like this: >>>>> 1. the center of the box would be located at x and bottom and top >>>>> would be y1, y2, all in data coords >>>>> 2. I would move to (x,y1) at the bottom-center of the box. >>>>> 3. The x value would now need to be converted to Axes coords, possibly >>>>> by applying transData + transAxes.inverted >>>>> 4. I would want to draw a line to (x-0.1, y1) where x is now in axes >>>>> coords and y is still in data coords. Then up, then right, then down, >>>>> and then close the polygon. >>>>> >>>>> How do I implement this? >>>>> >>>> >>>> I must be missing something, because I still don't see why you can't do >>>> all this very simply by using a PolyCollection, with the vertices in axes >>>> coordinates and the offset in data coordinates. >>>> >>>> Eric >>>> >>>> >>>>> >>>>> As I mentioned before, a blended transform would allow me to make the >>>>> moves i am interested in. However, a change of scale would change the >>>>> correspondence between data and axes coords, so the axes transform >>>>> part of the blended axes would have to be recomputed everytime the >>>>> scale changes based on where the (x,y1) point lands in the axes. Is >>>>> this correct? >>>>> >>>>> Any suggestions are welcome...thanks! >>>>> >>>>> Uri >>>>> >>>>> >>>>> >>>> >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> Come build with us! The BlackBerry® Developer Conference in SF, CA >>>> is the only developer event you need to attend this year. Jumpstart your >>>> developing skills, take BlackBerry mobile applications to market and stay >>>> ahead of the curve. Join us from November 9-12, 2009. Register now! >>>> http://p.sf.net/sfu/devconf >>>> _______________________________________________ >>>> Matplotlib-users mailing list >>>> Mat...@li... >>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>>> >>> >>> -- >>> Michael Droettboom >>> Science Software Branch >>> Operations and Engineering Division >>> Space Telescope Science Institute >>> Operated by AURA for NASA >>> >>> >> >> >> >> -- >> Uri Laserson >> PhD Candidate, Biomedical Engineering >> Harvard Medical School (Genetics) >> Massachusetts Institute of Technology (Mathematics) >> phone +1 917 742 8019 >> las...@mi... >> >> ------------------------------------------------------------------------------ >> Come build with us! The BlackBerry® Developer Conference in SF, CA >> is the only developer event you need to attend this year. Jumpstart your >> developing skills, take BlackBerry mobile applications to market and stay >> ahead of the curve. Join us from November 9-12, 2009. Register now! >> http://p.sf.net/sfu/devconf >> _______________________________________________ >> Matplotlib-users mailing list >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> > -- Uri Laserson PhD Candidate, Biomedical Engineering Harvard Medical School (Genetics) Massachusetts Institute of Technology (Mathematics) phone +1 917 742 8019 las...@mi...
Hi Mike, This is definitely on the right track. Thanks a lot for writing it out. When I change the view limits, indeed the width stays constant while the height gets rescaled. However, when I try to change to a logarithmic axis, I get the following errors. Again, excuse my ignorance, but I am not sure where exactly the offense is and how to fix it. In [57]: ax.set_xscale('log') In [58]: plt.draw() ERROR: An unexpected error occurred while tokenizing input The following traceback may be corrupted or invalid The error message is: ('EOF in multi-line statement', (568, 0)) ERROR: An unexpected error occurred while tokenizing input The following traceback may be corrupted or invalid The error message is: ('EOF in multi-line statement', (568, 0)) ERROR: An unexpected error occurred while tokenizing input The following traceback may be corrupted or invalid The error message is: ('EOF in multi-line statement', (568, 0)) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /Users/laserson/Desktop/<ipython console> in <module>() /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/pyplot.pyc in draw() 348 def draw(): 349 'redraw the current figure' --> 350 get_current_fig_manager().canvas.draw() 351 352 @docstring.copy_dedent(Figure.savefig) /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/backends/backend_tkagg.pyc in draw(self) 213 214 def draw(self): --> 215 FigureCanvasAgg.draw(self) 216 tkagg.blit(self._tkphoto, self.renderer._renderer, colormode=2) 217 self._master.update_idletasks() /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/backends/backend_agg.pyc in draw(self) 376 377 self.renderer = self.get_renderer() --> 378 self.figure.draw(self.renderer) 379 380 def get_renderer(self): /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *kl) 53 def draw_wrapper(artist, renderer, *kl): 54 before(artist, renderer) ---> 55 draw(artist, renderer, *kl) 56 after(artist, renderer) 57 /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/figure.pyc in draw(self, renderer) 770 771 # render the axes --> 772 for a in self.axes: a.draw(renderer) 773 774 # render the figure text /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *kl) 53 def draw_wrapper(artist, renderer, *kl): 54 before(artist, renderer) ---> 55 draw(artist, renderer, *kl) 56 after(artist, renderer) 57 /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/axes.pyc in draw(self, renderer, inframe) 1743 1744 for zorder, i, a in dsu: -> 1745 a.draw(renderer) 1746 1747 renderer.close_group('axes') /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *kl) 53 def draw_wrapper(artist, renderer, *kl): 54 before(artist, renderer) ---> 55 draw(artist, renderer, *kl) 56 after(artist, renderer) 57 /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/patches.pyc in draw(self, renderer) 353 354 path = self.get_path() --> 355 transform = self.get_transform() 356 tpath = transform.transform_path_non_affine(path) 357 affine = transform.get_affine() /Users/laserson/Desktop/testMyPatch.py in get_transform(self) 22 box = [[self.x, self.y1], 23 [self.x, self.y2]] ---> 24 box = self.axes.transData.transform(box) 25 26 # Get the width as a fraction of the axes width /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/transforms.pyc in transform(self, points) 1893 def transform(self, points): 1894 return self._b.transform( -> 1895 self._a.transform(points)) 1896 transform.__doc__ = Transform.transform.__doc__ 1897 /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/transforms.pyc in transform(self, points) 1721 x_points = x.transform(points)[:, 0:1] 1722 else: -> 1723 x_points = x.transform(points[:, 0]) 1724 x_points = x_points.reshape((len(x_points), 1)) 1725 TypeError: list indices must be integers On Mon, Sep 28, 2009 at 16:56, Michael Droettboom <md...@st...> wrote: > Is the attached sort of what you want? It defines a custom rectangle by (x, > w, y1, y2) and overrides the get_transform of the patch to update itself at > draw time. > > Mike > > Uri Laserson wrote: >> >> On Mon, Sep 28, 2009 at 16:03, Michael Droettboom <md...@st...> wrote: >> >>> >>> If I understand correctly, the top and bottom of the box are in data >>> coordinates, the x-center of the box is in data coordinates, only the >>> width >>> of the box is in axes coordinates. Is that correct? If so, a >>> >> >> That's exactly correct. >> >> >>> >>> PolyCollection won't be able to do this (directly), since that would >>> require >>> both the width and height to be in axes coordinates. >>> >> >> In principle, could you use a blended tranform for that? Eitherway, I >> don't think it would work, because the patch objects would be drawn to >> specific Axes coords. If the scale is changed (e.g, by switching to >> log scale), then what would prompt the Axes coords to be recalculated? >> I was thinking earlier that I could compose the transData and >> transAxes.inverse transforms to recalculate where the new Axes coord >> should be, but Mike thought this approach would fail (though I'm still >> not exactly sure why, no doubt because of my own ignorance). >> >> Uri >> >> >>> >>> Mike >>> >>> Eric Firing wrote: >>> >>>> >>>> Uri Laserson wrote: >>>> >>>> >>>>> >>>>> Is it possible to specify a path object that will use different >>>>> transforms for different vertices? >>>>> >>>>> This is again related to plotting a box whose height is specified by >>>>> data coords, but whose width is a constant in axes coords regardless >>>>> of scale (so linear and log x-scales would produce a box of the same >>>>> width). >>>>> >>>>> Ideally, I would draw a path like this: >>>>> 1. the center of the box would be located at x and bottom and top >>>>> would be y1, y2, all in data coords >>>>> 2. I would move to (x,y1) at the bottom-center of the box. >>>>> 3. The x value would now need to be converted to Axes coords, possibly >>>>> by applying transData + transAxes.inverted >>>>> 4. I would want to draw a line to (x-0.1, y1) where x is now in axes >>>>> coords and y is still in data coords. Then up, then right, then down, >>>>> and then close the polygon. >>>>> >>>>> How do I implement this? >>>>> >>>>> >>>> >>>> I must be missing something, because I still don't see why you can't do >>>> all this very simply by using a PolyCollection, with the vertices in >>>> axes >>>> coordinates and the offset in data coordinates. >>>> >>>> Eric >>>> >>>> >>>> >>>>> >>>>> As I mentioned before, a blended transform would allow me to make the >>>>> moves i am interested in. However, a change of scale would change the >>>>> correspondence between data and axes coords, so the axes transform >>>>> part of the blended axes would have to be recomputed everytime the >>>>> scale changes based on where the (x,y1) point lands in the axes. Is >>>>> this correct? >>>>> >>>>> Any suggestions are welcome...thanks! >>>>> >>>>> Uri >>>>> >>>>> >>>>> >>>>> >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> Come build with us! The BlackBerry® Developer Conference in SF, CA >>>> is the only developer event you need to attend this year. Jumpstart your >>>> developing skills, take BlackBerry mobile applications to market and >>>> stay >>>> ahead of the curve. Join us from November 9-12, 2009. Register >>>> now! >>>> http://p.sf.net/sfu/devconf >>>> _______________________________________________ >>>> Matplotlib-users mailing list >>>> Mat...@li... >>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>>> >>>> >>> >>> -- >>> Michael Droettboom >>> Science Software Branch >>> Operations and Engineering Division >>> Space Telescope Science Institute >>> Operated by AURA for NASA >>> >>> >>> >> >> >> >> > > -- > Michael Droettboom > Science Software Branch > Operations and Engineering Division > Space Telescope Science Institute > Operated by AURA for NASA > > > import numpy as np > import matplotlib.pyplot as plt > import matplotlib.patches as mpatches > import matplotlib.transforms as mtransforms > import matplotlib.path as mpath > > class MyBox(mpatches.Patch): > > def __init__(self, x, w, y1, y2, **kwargs): > self.x = x > self.w = w > self.y1 = y1 > self.y2 = y2 > mpatches.Patch.__init__(self, **kwargs) > > def get_path(self): > return mpath.Path.unit_rectangle() > > def get_transform(self): > > # Transform the data-relative values > box = [[self.x, self.y1], > [self.x, self.y2]] > box = self.axes.transData.transform(box) > > # Get the width as a fraction of the axes width > w = self.w * self.axes.bbox.width / 2.0 > > # Add it to the data-transformed coordinates > box[0][0] -= w > box[1][0] += w > > return mtransforms.BboxTransformTo(mtransforms.Bbox(box)) > > fig = plt.figure() > ax = fig.add_subplot(111) > patch = MyBox(0, 0.1, 0.5, 1.5) > ax.add_patch(patch) > ax.set_xlim((-1, 1)) > ax.set_ylim((0, 2)) > > plt.show() > > -- Uri Laserson PhD Candidate, Biomedical Engineering Harvard Medical School (Genetics) Massachusetts Institute of Technology (Mathematics) phone +1 917 742 8019 las...@mi...
Hmm, I'm afraid that this only works if you use preview mode. I haven't tested, but I guess it will fail without it. Check if rcParams["text.latex.preview"]==True. -JJ On Mon, Sep 28, 2009 at 6:26 PM, Jae-Joon Lee <lee...@gm...> wrote: > You need an empty mbox at the end of line (\mbox{}). > > text(xlim()[1],1.02,r'$r^2$~~~\mbox{}',horizontalalignment='right') > > If you did mean \; after ^, it requires {}. > > Again, these only works if you use real TeX for text rendering (ie > usetex=True), not the mpl's mathtext mode. > > Regards, > > -JJ > > > On Mon, Sep 28, 2009 at 5:48 PM, Christopher Barrington-Leigh > <cpb...@gm...> wrote: >> >> All my attempts at using TeX spacing failed too. What do you have in mind? >> >> e.g. >> text(xlim()[1],1.02,r'$r^\;2$~~~',horizontalalignment='right') >> >> >> Jae-Joon Lee wrote: >>> >>> While I think you're not using usetex mode, you may use tex's own >>> spacing command with usetex mode. Depending on your need, you may also >>> use the annotate function with which you can provide a spacing in >>> pixel coordinate (or other coordinate the annotate supports). >>> >> >> -- >> View this message in context: http://www.nabble.com/trailing-space-in-text-string-stripped%2C-making-it-impossible-to-right-pad-my-text-tp25639703p25653573.html >> Sent from the matplotlib - users mailing list archive at Nabble.com. >> >> >> ------------------------------------------------------------------------------ >> Come build with us! The BlackBerry® Developer Conference in SF, CA >> is the only developer event you need to attend this year. Jumpstart your >> developing skills, take BlackBerry mobile applications to market and stay >> ahead of the curve. Join us from November 9-12, 2009. Register now! >> http://p.sf.net/sfu/devconf >> _______________________________________________ >> Matplotlib-users mailing list >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >
You need an empty mbox at the end of line (\mbox{}). text(xlim()[1],1.02,r'$r^2$~~~\mbox{}',horizontalalignment='right') If you did mean \; after ^, it requires {}. Again, these only works if you use real TeX for text rendering (ie usetex=True), not the mpl's mathtext mode. Regards, -JJ On Mon, Sep 28, 2009 at 5:48 PM, Christopher Barrington-Leigh <cpb...@gm...> wrote: > > All my attempts at using TeX spacing failed too. What do you have in mind? > > e.g. > text(xlim()[1],1.02,r'$r^\;2$~~~',horizontalalignment='right') > > > Jae-Joon Lee wrote: >> >> While I think you're not using usetex mode, you may use tex's own >> spacing command with usetex mode. Depending on your need, you may also >> use the annotate function with which you can provide a spacing in >> pixel coordinate (or other coordinate the annotate supports). >> > > -- > View this message in context: http://www.nabble.com/trailing-space-in-text-string-stripped%2C-making-it-impossible-to-right-pad-my-text-tp25639703p25653573.html > Sent from the matplotlib - users mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry® Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9-12, 2009. Register now! > http://p.sf.net/sfu/devconf > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >
Greetings, I would like to plot to make a figure with 3 subplots of the form (221) to (223): - each subplot should show a bar3d plot of a matrix - each subplot should have it's own title The problems: a) I don't see (nor did i find something) how i can use subplots combined with bar3d (from the mpl_toolkits.mplot3d) package. b) I don't manage to give the 3d bar plot a title. In the attached code you will see that a title is set, but it does not show up in the figure Could someone please help me out with these problems? Thanks, q --------------------- The code for the basic plot of the matrix: from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt from matplotlib.ticker import FixedFormatter, LinearLocator, FixedLocator from numpy import * psi=1/sqrt(2)*array([1, 0, 0, 1]) rho=outer(psi,psi) fig = plt.figure() ax = Axes3D(fig) elements = (len(rho) * len(rho)) xpos, ypos = meshgrid(array(range(len(rho)))+0.25, array(range(len(rho)))+0.25) xpos = xpos.flatten() ypos = ypos.flatten() zpos = zeros(elements) dx = 0.5 * ones_like(zpos) dy = dx.copy() dz = absolute(rho.flatten()) ax.set_title('absolute') ax.bar3d(xpos, ypos, zpos, dx, dy, dz, color='#F8F800') plt.show()
On Mon, Sep 28, 2009 at 4:54 PM, Jeff Whitaker <js...@fa...> wrote: > Ryan May wrote: >> >> Jeff, >> >> Right now, for me, any Basemap example that uses colorbar() is broken >> for me. I think there's a problem with how Basemap sets the current >> 'image' so that a colorbar can be automatically generated for plots. >> The code currently does: >> >> plt.gci._current = ret >> >> I think the current image handling in matplotlib itself was reworked >> (at least according to SVN logs, r7494), so that now instead there's a >> setter function: >> >> plt.sci(ret) >> >> I'd be happy fix these myself if you're too busy. >> >> Ryan >> >> > > Ryan: I'm off to Australia for a conference tomorrow, so if you could fix > that I'd be grateful. I wonder if we shouldn't wrap the old > plt.gci._current = ret in a try/except, and use the new way if an Attribute > Error is raised. That way, it will still work with old versions of > matplotlib. Trying both sounds like a good idea, since I just noticed this change is only in SVN trunk, and not in the 0.99.x series (which is probably why no one noticed). However, no attribute error is raised when setting the attribute, it's just never used. I'll see if I can come up with something similar that will work. Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma Sent from Norman, Oklahoma, United States
Ryan May wrote: > Jeff, > > Right now, for me, any Basemap example that uses colorbar() is broken > for me. I think there's a problem with how Basemap sets the current > 'image' so that a colorbar can be automatically generated for plots. > The code currently does: > > plt.gci._current = ret > > I think the current image handling in matplotlib itself was reworked > (at least according to SVN logs, r7494), so that now instead there's a > setter function: > > plt.sci(ret) > > I'd be happy fix these myself if you're too busy. > > Ryan > > Ryan: I'm off to Australia for a conference tomorrow, so if you could fix that I'd be grateful. I wonder if we shouldn't wrap the old plt.gci._current = ret in a try/except, and use the new way if an Attribute Error is raised. That way, it will still work with old versions of matplotlib. Thanks for catching this. -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX : (303)497-6449 NOAA/OAR/PSD R/PSD1 Email : Jef...@no... 325 Broadway Office : Skaggs Research Cntr 1D-113 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg
Jeff, Right now, for me, any Basemap example that uses colorbar() is broken for me. I think there's a problem with how Basemap sets the current 'image' so that a colorbar can be automatically generated for plots. The code currently does: plt.gci._current = ret I think the current image handling in matplotlib itself was reworked (at least according to SVN logs, r7494), so that now instead there's a setter function: plt.sci(ret) I'd be happy fix these myself if you're too busy. Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma
All my attempts at using TeX spacing failed too. What do you have in mind? e.g. text(xlim()[1],1.02,r'$r^\;2$~~~',horizontalalignment='right') Jae-Joon Lee wrote: > > While I think you're not using usetex mode, you may use tex's own > spacing command with usetex mode. Depending on your need, you may also > use the annotate function with which you can provide a spacing in > pixel coordinate (or other coordinate the annotate supports). > -- View this message in context: http://www.nabble.com/trailing-space-in-text-string-stripped%2C-making-it-impossible-to-right-pad-my-text-tp25639703p25653573.html Sent from the matplotlib - users mailing list archive at Nabble.com.
Thanks. Unfortunately this gives me the same results: no good. Something is stripping whatever filler is there on the right. text(xlim()[1],1.01,'string'.ljust(10,' '),horizontalalignment='right') John [H2O] wrote: > > > > Christopher Barrington-Leigh wrote: >> >> Hello. My problem is as follows: >> (ipython --pylab) >> >> from pylab import * >> pp=plot([0,0],[1,1]) >> text(xlim()[0],1,' Need padding ',horizontalalignment='left') >> text(xlim()[1],1,' Need padding ',horizontalalignment='right') >> >> >> The second case does not do what I want, which is to pad the text on the >> right. Text strings are stripped on the right, but no on the left. How >> can I elegantly create a character of space? >> >> Thanks! >> c >> > > Untested, but I think you could do this with just python builtin types: > > from pylab import * > pp=plot([0,0],[1,1]) > text(xlim()[0],1,'string'.ljust(10,' ')) > text(xlim()[1],1,'string'.rjust(10,' ')) > > See the documention: > http://docs.python.org/library/stdtypes.html > > str.ljust(width[, fillchar])¶ > > Return the string left justified in a string of length width. Padding is > done using the specified fillchar (default is a space). The original > string is returned if width is less than len(s). > > Changed in version 2.4: Support for the fillchar argument. > > > -- View this message in context: http://www.nabble.com/trailing-space-in-text-string-stripped%2C-making-it-impossible-to-right-pad-my-text-tp25639703p25653331.html Sent from the matplotlib - users mailing list archive at Nabble.com.
Thanks. Unfortunately this gives me the same results: no good. Something is stripping whatever filler is there on the right. text(xlim()[1],1.01,'string'.ljust(10,' '),horizontalalignment='right') John [H2O] wrote: > > Untested, but I think you could do this with just python builtin types: > > from pylab import * > pp=plot([0,0],[1,1]) > text(xlim()[0],1,'string'.ljust(10,' ')) > text(xlim()[1],1,'string'.rjust(10,' ')) > > See the documention: > http://docs.python.org/library/stdtypes.html > > str.ljust(width[, fillchar])¶ > > Return the string left justified in a string of length width. Padding is > done using the specified fillchar (default is a space). The original > string is returned if width is less than len(s). > > Changed in version 2.4: Support for the fillchar argument. > > > -- View this message in context: http://www.nabble.com/trailing-space-in-text-string-stripped%2C-making-it-impossible-to-right-pad-my-text-tp25639703p25653325.html Sent from the matplotlib - users mailing list archive at Nabble.com.
I can confirm this with latest svn. I take a quick look at the code, but couldn't figure where the stripping happens and I hope other experts to step in. While I think you're not using usetex mode, you may use tex's own spacing command with usetex mode. Depending on your need, you may also use the annotate function with which you can provide a spacing in pixel coordinate (or other coordinate the annotate supports). Regards, -JJ On Sun, Sep 27, 2009 at 9:57 PM, Christopher Barrington-Leigh <cpb...@gm...> wrote: > > Hello. My problem is as follows: > (ipython --pylab) > > from pylab import * > pp=plot([0,0],[1,1]) > text(xlim()[0],1,' Need padding ',horizontalalignment='left') > text(xlim()[1],1,' Need padding ',horizontalalignment='right') > > > The second case does not do what I want, which is to pad the text on the > right. Text strings are stripped on the right, but no on the left. How can I > elegantly create a character of space? > > Thanks! > c > -- > View this message in context: http://www.nabble.com/trailing-space-in-text-string-stripped%2C-making-it-impossible-to-right-pad-my-text-tp25639703p25639703.html > Sent from the matplotlib - users mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry® Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9-12, 2009. Register now! > http://p.sf.net/sfu/devconf > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >
Ralph Kube-2 wrote: > > > Is there an > easy way out? > > Well, you could just script it and create .png files.... I do it all the time. -- View this message in context: http://www.nabble.com/Update-a-contour-plot-tp25648878p25653140.html Sent from the matplotlib - users mailing list archive at Nabble.com.
Christopher Barrington-Leigh wrote: > > Hello. My problem is as follows: > (ipython --pylab) > > from pylab import * > pp=plot([0,0],[1,1]) > text(xlim()[0],1,' Need padding ',horizontalalignment='left') > text(xlim()[1],1,' Need padding ',horizontalalignment='right') > > > The second case does not do what I want, which is to pad the text on the > right. Text strings are stripped on the right, but no on the left. How can > I elegantly create a character of space? > > Thanks! > c > Untested, but I think you could do this with just python builtin types: from pylab import * pp=plot([0,0],[1,1]) text(xlim()[0],1,'string'.ljust(10,' ')) text(xlim()[1],1,'string'.rjust(10,' ')) See the documention: http://docs.python.org/library/stdtypes.html str.ljust(width[, fillchar])¶ Return the string left justified in a string of length width. Padding is done using the specified fillchar (default is a space). The original string is returned if width is less than len(s). Changed in version 2.4: Support for the fillchar argument. -- View this message in context: http://www.nabble.com/trailing-space-in-text-string-stripped%2C-making-it-impossible-to-right-pad-my-text-tp25639703p25653102.html Sent from the matplotlib - users mailing list archive at Nabble.com.