SourceForge logo
SourceForge logo
Menu

matplotlib-users — Discussion related to using matplotlib

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)





Showing results of 399

<< < 1 2 3 4 .. 16 > >> (Page 2 of 16)
From: Jeff L. <lay...@at...> - 2011年02月25日 12:19:43
 On 02/23/2011 09:50 AM, Benjamin Root wrote:
> On Wed, Feb 23, 2011 at 8:34 AM, Jeff Layton <lay...@at... 
> <mailto:lay...@at...>> wrote:
>
> Good morning,
>
> I'm looking for examples of creating a bar chart and then adding
> a line chart on top of it (with the same y-axis). I haven't had
> much luck with Google (probably using the wrong search terms).
>
> Thanks!
>
> Jeff
>
>
> Jeff,
>
> You should be able to just call the bar() function and then call the 
> plot() function using the same axes object. For example (untested):
>
> import numpy as np
> import matplotlib.pyplot as plt
>
>
> fig = plt.figure()
> ax = fig.gca()
>
> xs = np.arange(10)
> ys = np.random.rand(10)
>
> ax.bar(xs, ys)
> ax.plot(xs, ys)
>
> plt.show()
>
>
> I hope that helps!
> Ben Root
That worked perfectly! I guess I was looking for something
more complicated and it was that simple.
Thanks!
Jeff
From: Daniel M. <dan...@go...> - 2011年02月25日 11:03:42
Hi Goyo and Darren,
thanks for pointing out the rcParams solution! For the time being,
this seems an OK approach. I'd like to use the automatic solution,
though, but this does not seem to work:
import matplotlib.pyplot as plt
import matplotlib.transforms as mtransforms
import numpy,pylab,matplotlib.ticker as mtick
x = numpy.linspace(0,10,1000)
y = numpy.exp(x)
pylab.rcdefaults()
def on_draw(event):
 bboxes = []
 for label in labels:
 bbox = label.get_window_extent()
 # the figure transform goes from relative coords->pixels and we
 # want the inverse of that
 bboxi = bbox.inverse_transformed(fig.transFigure)
 bboxes.append(bboxi)
 # this is the bbox that bounds all the bboxes, again in relative
 # figure coords
 bbox = mtransforms.Bbox.union(bboxes)
 if fig.subplotpars.left < bbox.width:
 # we need to move it over
 fig.subplots_adjust(left=1.1*bbox.width) # pad a little
 fig.canvas.draw()
 return False
fig = pylab.figure(figsize=(5,3))
ax = fig.add_subplot(111)
ax.set_yscale('log')
ax.yaxis.set_major_formatter(mtick.FormatStrFormatter('%d'))
ax.set_xlabel('asdf')
ax.set_ylabel('qwer')
ax.plot(x,y)
labels = ax.get_yticklabels()
fig.canvas.mpl_connect('draw_event', on_draw)
fig.savefig('example_mpl-ticker_2')
2011年2月25日 Darren Dale <dsd...@gm...>:
> On Tue, Feb 22, 2011 at 4:23 AM, Daniel Mader
> <dan...@go...> wrote:
>> Hi,
>>
>> there has been a similar question recently but I couldn't figure out
>> if or how this is solved:
>>
>> I'd like to reduce the figure size so that I can add it to a LaTeX
>> document without scaling (PDF output with LaTeX font rendering). For
>> that, I need to adapt the font sizes, too.
>>
>> Unfortunately, the canvas is not properly scaled so that the axis
>> labels and the possibly the tick marks are cut off.
>>
>> Is this a bug, feature, design flaw? How can I properly work around
>> it, i.e. reduce the graph automatically for a given figsize/font size
>> combination so that everything fits on the figure?
>>
>> An example follows to demonstrate, thanks in advance
>
> I use matplotlib for this purpose pretty frequently. A few tricks:
>
> from http://matplotlib.sourceforge.net/users/customizing.html :
> # note that font.size controls default text sizes. To configure
> # special text sizes tick labels, axes, labels, title, etc, see the rc
> # settings for axes and ticks. Special text sizes can be defined
> # relative to font.size, using the following values: xx-small, x-small,
> # small, medium, large, x-large, xx-large, larger, or smaller
>
> # specify the figure canvas size, in inches
> figure(figsize=(3.4, 4))
>
> # place the axes in the figure window
> # specifying (left, bottom, width, height) as fraction of figure size
> # adjust those positions to make enough room for tick and axis labels
> axes([0.15, 0.12, 0.8, 0.83])
>
> Specify the dpi for you screen, so the figure rendered on your screen
> is the correct size. This is figure.dpi, best to set it in
> matplotlibrc.
>
> Darren
>
-- 
Zugallistr. 11/14
5020 Salzburg
M_at +43 699 10 54 54 53
T_at +43 662 841635
M_de +49 179 2300317
E dan...@go...
From: Paul L. <pau...@ii...> - 2011年02月25日 10:14:48
Hi Benjamin,
> > On 2011年2月16日 03:07:25 AM you wrote:
> > > I have not figured out what is causing the difference between my
> > > computers.
> > > This might be backend-dependent (and maybe version-dependent). Have
> > > you tested your code on different backends?
Sorry for my delay in replying. I have had a busy week. I've now tested my PC 
running OpenSUSE 11.2 with python-matplotlib-1.0.1-20.1.x86_64. 
I ran ipython -pylab with various values for "backend=" in the matplotlibrc 
file.
The results for all listed backends follow.
Best, Paul
# No figures are displayed:
Agg,Cairo,GDK,PS,PDF,SVG,Template
# Bug: Last plot is displayed in all figures:
GTK,GTKAgg,GTKCairo,TkAgg,WXAgg
# Two Bugs: Figures remain blank until last plot completed. 
# Last plot is displayed in all figures.
Qt4Agg
# Failed with error message:
CocoaAgg
# The CococaAgg backend required PyObjC to be installed!
# (currently testing v1.3.7)
FltkAgg
#ImportError: No module named fltk
MacOSX
#ImportError: cannot import name _macosx
QtAgg
# RuntimeError: the sip module implements API v8.0 to v8.1 but the qt module 
requires API v7.1
WX
# NotImplementedError: wx.GraphicsContext is not available on this platform.
From: Michele M. <mat...@gm...> - 2011年02月25日 01:42:19
Following up, after a bit of research...
It seems it's alla about QString (which is gone in api 2)
it is suggested to convert the QString into a unicode python2 string
http://wiki.python.org/moin/PortingPythonToPy3k/PyQt4
Do you think could be the way to go for the qt backend?
Cheers,
Michele.
On Fri, Feb 25, 2011 at 12:30 AM, Michele Mattioni <mat...@gm...> wrote:
> Dear list,
>
> I'm trying to to use matplotlib in a Qt application which needs the
> sip API set to 2
>
>    import sip
>    sip.setapi('QString', 2)
>
> However if I do this I get this error
>
>    ImportError: cannot import name QString
>
> I'm wondering if I'm the first to stumble upon this one, or this is a
> known solution.
>
> Below the whole Traceback.
>
> Thanks,
> Michele.
>
>
>    In [3]: import sip
>
>    In [4]: sip.setapi('QString', 2)
>
>    In [5]: import matplotlib.pyplot as plt
>    ---------------------------------------------------------------------------
>    ImportError                Traceback (most recent call last)
>
>    /home/mattions/Work/model/MSN/Neuronvisio/examples/<ipython console>
> in <module>()
>
>    /usr/lib/pymodules/python2.6/matplotlib/pyplot.py in <module>()
>         93
>         94 from matplotlib.backends import pylab_setup
>    ---> 95 new_figure_manager, draw_if_interactive, show = pylab_setup()
>         96
>         97 @docstring.copy_dedent(Artist.findobj)
>
>    /usr/lib/pymodules/python2.6/matplotlib/backends/__init__.pyc in pylab_setup()
>         23     backend_name = 'matplotlib.backends.%s'%backend_name.lower()
>         24   backend_mod = __import__(backend_name,
>    ---> 25               globals(),locals(),[backend_name])
>         26
>         27   # Things we pull in from all backends
>
>
>    /usr/lib/pymodules/python2.6/matplotlib/backends/backend_qt4agg.py in
> <module>()
>         10
>         11 from backend_agg import FigureCanvasAgg
>    ---> 12 from backend_qt4 import QtCore, QtGui, FigureManagerQT,
> FigureCanvasQT,\
>         13   show, draw_if_interactive, backend_version, \
>         14   NavigationToolbar2QT
>
>    /usr/lib/pymodules/python2.6/matplotlib/backends/backend_qt4.py in <module>()
>         14 from matplotlib.mathtext import MathTextParser
>         15 from matplotlib.widgets import SubplotTool
>    ---> 16 import matplotlib.backends.qt4_editor.figureoptions as figureoptions
>         17
>         18 try:
>
>    /usr/lib/pymodules/python2.6/matplotlib/backends/qt4_editor/figureoptions.py
> in <module>()
>         9 import os.path as osp
>         10
>    ---> 11 import matplotlib.backends.qt4_editor.formlayout as formlayout
>         12 from PyQt4.QtGui import QIcon
>         13
>
>    /usr/lib/pymodules/python2.6/matplotlib/backends/qt4_editor/formlayout.py
> in <module>()
>         57             QDateEdit, QDateTimeEdit, QFont, QFontComboBox,
>         58             QFontDatabase, QGridLayout)
>    ---> 59 from PyQt4.QtCore import (Qt, SIGNAL, SLOT, QSize, QString,
>         60              pyqtSignature, pyqtProperty)
>         61 from datetime import date
>
>    ImportError: cannot import name QString
>
From: Michele M. <mat...@gm...> - 2011年02月25日 00:30:19
Dear list,
I'm trying to to use matplotlib in a Qt application which needs the
sip API set to 2
	import sip
	sip.setapi('QString', 2)
However if I do this I get this error
	ImportError: cannot import name QString
I'm wondering if I'm the first to stumble upon this one, or this is a
known solution.
Below the whole Traceback.
Thanks,
Michele.
	In [3]: import sip
	In [4]: sip.setapi('QString', 2)
	In [5]: import matplotlib.pyplot as plt
	---------------------------------------------------------------------------
	ImportError Traceback (most recent call last)
	/home/mattions/Work/model/MSN/Neuronvisio/examples/<ipython console>
in <module>()
	/usr/lib/pymodules/python2.6/matplotlib/pyplot.py in <module>()
		 93
		 94 from matplotlib.backends import pylab_setup
	---> 95 new_figure_manager, draw_if_interactive, show = pylab_setup()
		 96
		 97 @docstring.copy_dedent(Artist.findobj)
	/usr/lib/pymodules/python2.6/matplotlib/backends/__init__.pyc in pylab_setup()
		 23 backend_name = 'matplotlib.backends.%s'%backend_name.lower()
		 24 backend_mod = __import__(backend_name,
	---> 25 globals(),locals(),[backend_name])
		 26
		 27 # Things we pull in from all backends
	/usr/lib/pymodules/python2.6/matplotlib/backends/backend_qt4agg.py in
<module>()
		 10
		 11 from backend_agg import FigureCanvasAgg
	---> 12 from backend_qt4 import QtCore, QtGui, FigureManagerQT,
FigureCanvasQT,\
		 13 show, draw_if_interactive, backend_version, \
		 14 NavigationToolbar2QT
	/usr/lib/pymodules/python2.6/matplotlib/backends/backend_qt4.py in <module>()
		 14 from matplotlib.mathtext import MathTextParser
		 15 from matplotlib.widgets import SubplotTool
	---> 16 import matplotlib.backends.qt4_editor.figureoptions as figureoptions
		 17
		 18 try:
	/usr/lib/pymodules/python2.6/matplotlib/backends/qt4_editor/figureoptions.py
in <module>()
		 9 import os.path as osp
		 10
	---> 11 import matplotlib.backends.qt4_editor.formlayout as formlayout
		 12 from PyQt4.QtGui import QIcon
		 13
	/usr/lib/pymodules/python2.6/matplotlib/backends/qt4_editor/formlayout.py
in <module>()
		 57 QDateEdit, QDateTimeEdit, QFont, QFontComboBox,
		 58 QFontDatabase, QGridLayout)
	---> 59 from PyQt4.QtCore import (Qt, SIGNAL, SLOT, QSize, QString,
		 60 pyqtSignature, pyqtProperty)
		 61 from datetime import date
	ImportError: cannot import name QString
From: Darren D. <dsd...@gm...> - 2011年02月25日 00:18:40
On Tue, Feb 22, 2011 at 4:23 AM, Daniel Mader
<dan...@go...> wrote:
> Hi,
>
> there has been a similar question recently but I couldn't figure out
> if or how this is solved:
>
> I'd like to reduce the figure size so that I can add it to a LaTeX
> document without scaling (PDF output with LaTeX font rendering). For
> that, I need to adapt the font sizes, too.
>
> Unfortunately, the canvas is not properly scaled so that the axis
> labels and the possibly the tick marks are cut off.
>
> Is this a bug, feature, design flaw? How can I properly work around
> it, i.e. reduce the graph automatically for a given figsize/font size
> combination so that everything fits on the figure?
>
> An example follows to demonstrate, thanks in advance
I use matplotlib for this purpose pretty frequently. A few tricks:
from http://matplotlib.sourceforge.net/users/customizing.html :
# note that font.size controls default text sizes. To configure
# special text sizes tick labels, axes, labels, title, etc, see the rc
# settings for axes and ticks. Special text sizes can be defined
# relative to font.size, using the following values: xx-small, x-small,
# small, medium, large, x-large, xx-large, larger, or smaller
# specify the figure canvas size, in inches
figure(figsize=(3.4, 4))
# place the axes in the figure window
# specifying (left, bottom, width, height) as fraction of figure size
# adjust those positions to make enough room for tick and axis labels
axes([0.15, 0.12, 0.8, 0.83])
Specify the dpi for you screen, so the figure rendered on your screen
is the correct size. This is figure.dpi, best to set it in
matplotlibrc.
Darren
From: Tommy G. <tg...@ma...> - 2011年02月25日 00:00:48
Is there a 64bit installer of matplotlib for mac os x available?
Cheers
 Tommy
From: Goyo <goy...@gm...> - 2011年02月24日 23:02:15
2011年2月22日 Benjamin Root <ben...@ou...>:
>
> Admittedly, this isn't using matplotlib's hist() function because it only
> allows for one color per dataset. However, you can use numpy's histogram
> function to get the bins and counts yourself, and then use bar() to make the
> bars. bar() will allow you to color the bars individually.
Pylab hist() returns a list of patches so you can also change their properties.
Goyo
From: Goyo <goy...@gm...> - 2011年02月24日 22:49:12
2011年2月22日 Daniel Mader <dan...@go...>:
> Hi,
>
> there has been a similar question recently but I couldn't figure out
> if or how this is solved:
>
> I'd like to reduce the figure size so that I can add it to a LaTeX
> document without scaling (PDF output with LaTeX font rendering). For
> that, I need to adapt the font sizes, too.
>
> Unfortunately, the canvas is not properly scaled so that the axis
> labels and the possibly the tick marks are cut off.
>
> Is this a bug, feature, design flaw? How can I properly work around
> it, i.e. reduce the graph automatically for a given figsize/font size
> combination so that everything fits on the figure?
You'll have to understand how dimensions are calculated and then use
stuff like Figure.subplots_adjust.
http://matplotlib.sourceforge.net/api/figure_api.html#matplotlib.figure.Figure.subplots_adjust
http://matplotlib.sourceforge.net/api/figure_api.html#matplotlib.figure.SubplotParams
http://matplotlib.sourceforge.net/faq/howto_faq.html#automatically-make-room-for-tick-labels
As a fast and dirty trick you can pass big numbers to subplots_adjust
and then use bbox_inches='tight' in savefig.
Goyo
From: bhargav v. <coo...@gm...> - 2011年02月24日 18:07:17
> 
> 
> On Wed, Feb 23, 2011 at 2:09 PM, bhargav vaidya <coo...@gm...> wrote:
> Hello Matplotlib Users.
> 
> I am trying to work my way out to interpolate a surface from polar coordinates (R,Theta,Z) to rectangular co-ordinates(X,Y,Z)
> Basically I am looking for an equivalent for POLAR_SURFACE.pro routine in IDL using matplotlib/Scipy?
> 
> http://idlastro.gsfc.nasa.gov/idl_html_help/POLAR_SURFACE.html
> 
> Does anyone of you have done that before or could tell me what functions can I use to get that?
> 
> Regards
> Bhargav Vaidya
> 
> 
> (Quick Note: technically, you have cylindrical coordinates because you have Z, not Phi)
> 
> While I am sure there are some more optimal methods, the straight-forward way is to do something like the following:
> 
> import numpy as np
> from scipy.interpolate import griddata
> 
> orig_x = R*np.cos(Theta)
> orig_y = R*np.sin(Theta)
> orig_z = Z
> 
> grid_x, grid_y, grid_z = np.mgrid[orig_x.min():orig_x.max():10j,
> orig_y.min():orig_y.max():10j,
> orig_z.min():orig_z.max():10j]
> 
> new_vals = griddata((orig_x, orig_y, orig_z), orig_vals, (grid_x, grid_y, grid_z)
> 
> 
> After running this, you should have new_vals which should have the same shape as grid_x. You can also specify the interpolation method used by griddata through the 'method' keyword argument. The '10j' in the np.mgrid[] call merely specifies the number of points you want in that axis and can be changed to any other integer you want (just keep the 'j' there to make it work the way we want).
> 
> I hope that helps!
> Ben Root
> 
Hello Benjamin 
Thanks for the reply... I was a little vague in my first question before...
Here is my specific problem
I have a 3D matrix say of density (rho [ r, theta , phi] ) 
where r, theta ,phi have (64,32,32) elements
theta and phi values are in radians.
I have to interpolate rho(r, theta) at some phi to rho(x,z) and rho(r, phi) at some theta to rho(x,y) ....
However I used the a different code then the one you mentioned .. I am using the scipy.ndimage.geometric_transform
I am attaching the figure obtained using a code below 
THE PART OF THE CODE TO CONVERT THE POLAR TO CARTESIAN IS GIVEN BELOW
I have the following problems :
1. I am not happy with the interpolation. This is partly because I am using pcolormesh for plotting data as imshow is not working for my irregularly spaced grid. I have also tried higher order for the geometric -transform but the difference is not that appreciable. Can I improve the interpolation is some way?
2. In the right panels of the plot above, I dont get the radial and vertical co-ordinate as the right cartesian values.. I think this can be solved if I give the right x y and z values to pcolormesh ... but I am not sure how to get the right values for them so that they are consistent with the transform.
import numpy as np
import scipy as S
import scipy.ndimage
def get_polar_plot(self,var,**kwargs):
		def r2theta(outcoords, inputshape, origin):
			xindex, yindex = outcoords
			x0, y0 = origin
			x = xindex - x0
			y = yindex - y0
			r = np.sqrt(x**2 + y**2)
			theta = np.arctan2(np.pi-y, x)
			theta_index = np.round((theta+ np.pi) * inputshape[1] / (1.015*np.pi))
			return (r,theta_index)
		def r2phi(outcoords, inputshape, origin):
			xindex, yindex = outcoords
			x0, y0 = origin
			x = xindex - x0
			y = yindex - y0
			r = np.sqrt(x**2 + y**2)
			phi = np.arctan2(y, x)
			phi_index = np.round((phi + np.pi) * inputshape[1] / (2.1*np.pi))
			return (r,phi_index)
		x1 = kwargs.get('x1') # This is Radial co-ordinate
		x2 = kwargs.get('x2') # This is Either Theta or Phi
		data_arr2d = var
		if kwargs.get('rtheta',False) == True:
			var_cart = S.ndimage.geometric_transform(data_arr2d, r2theta,order=1,output_shape = (data_arr2d.shape[0]*2, data_arr2d.shape[0]),extra_keywords = {'inputshape':data_arr2d.shape,'origin':(data_arr2d.shape[0],0)})
		if kwargs.get('rphi',False) == True:
			var_cart = S.ndimage.geometric_transform(data_arr2d, r2phi, order=1,output_shape = (data_arr2d.shape[0]*2, data_arr2d.shape[0]*2),extra_keywords = {'inputshape':data_arr2d.shape,'origin':(data_arr2d.shape[0],data_arr2d.shape[0])})
		return var_cart
Hope you will help me in this regard.
Regards
Bhargav
From: Benjamin R. <ben...@ou...> - 2011年02月24日 15:48:23
On Wed, Feb 23, 2011 at 6:56 PM, Jack Sankey <jac...@gm...> wrote:
> Hi everyone!
>
> Is there any backend-independent way to get and set the figure window
> coordinates and sizes (i.e. in pixels)? Currently when I make new plots they
> appear in random locations as determined by my operating system; during
> analysis when I'm making and destroying a lot of plot windows I want to be
> able to have them automatically appear in "good" locations (such as the
> upper left corner of my screen).
>
> Also, I am trying to find ways to get/set the z-order.
>
> Thanks in advance,
> Jack
>
>
There was someone who found that it was possible to add some additional
information to the creation of a figure window. This information (at least
on Linux systems), could be taken advantage of by customized configurations
of the desktop manager. I would be curious to see what has come of that
effort.
Ben Root
From: Benjamin R. <ben...@ou...> - 2011年02月24日 15:44:42
On Wed, Feb 23, 2011 at 10:52 PM, Mark Janikas <mja...@es...> wrote:
> Hello All,
>
>
>
> Is there a way to add HTML links into output graphics? In short, I would
> like to use something like the PLT.text command and have it link to an html
> page. The url arg doesn’t seem to be what I am looking for.
>
>
>
> My final output medium is PDF... so I am using:
>
>
>
> from matplotlib.backends.backend_pdf import PdfPages as PDF
>
> import matplotlib.pyplot as PLT
>
>
>
>
>
> pdfOutput = PDF(fileName)
>
> PLT.text("Some Text to Link", url = "http:...")
>
> ...
>
> ...
>
> PLT.savefig(pdfOutput, format='pdf')
>
> PLT.clf()
>
>
>
>
>
> Thanks so much for any advise!
>
>
>
> MJ
>
>
Looks like the url string is only used for SVG files. If you could, please
file a feature request to have it added to the pdf backend:
https://sourceforge.net/tracker/?group_id=80706
Ben Root
From: Nadezhda D. <den...@st...> - 2011年02月24日 14:30:59
Jason,
Try adding a pyqt property 'facecolor' to your widget.
(This way you can set it also through the designer.)
Add something like this to the widget's __init__ method:
figFacecolor = QtCore.pyqtProperty(str, getfigfacecolor,
 setfigfacecolor, resetfigfacecolor)
And then define the three methods.
Nadia
From: gary r. <gr...@bi...> - 2011年02月24日 11:20:09
Attachments: jitter.py
I haven't seen this done before so I don't know if there's a standard
way. The idea seems to be to take some points which are real data,
create a random variable for each point with the points' position as
the mean, then choose some number of points from each distribution to
create some new points clustered around the original data. Some
examples online seem to use uniform distributions and Poisson
distributions or mixtures of these (uniform for the x-variable and
Poisson for the y). If my take on this is correct, you can use
scipy.stats to do this - an example is in the attached file which
creates Gaussian distributions for each of the x and y coordinates
then creates an equal number of new points for each of the seed
points. The online examples I saw seem to choose random numbers of new
points for each seed point. I didn't bother trying to cover all the
possibilities. Hopefully this is helpful,
Gary R.
On Thu, Feb 24, 2011 at 3:04 PM, Uri Laserson <las...@mi...> wrote:
> Hi all,
> I am interested in jittering points in a plot. I searched the forum, but I
> am amazed at the dearth of results on the topic. I am referring to
> something like this:
> http://goo.gl/Db47s
> or
> http://goo.gl/BjIZt
>
> Is there a standard way people do this with MPL?
> Thanks!
> Uri
> ...................................................................................
> Uri Laserson
> Graduate Student, Biomedical Engineering
> Harvard-MIT Division of Health Sciences and Technology
> M +1 917 742 8019
> las...@mi...
From: Mark J. <mja...@es...> - 2011年02月24日 04:52:54
Hello All,
Is there a way to add HTML links into output graphics? In short, I would like to use something like the PLT.text command and have it link to an html page. The url arg doesn't seem to be what I am looking for.
My final output medium is PDF... so I am using:
from matplotlib.backends.backend_pdf import PdfPages as PDF
import matplotlib.pyplot as PLT
pdfOutput = PDF(fileName)
PLT.text("Some Text to Link", url = "http:...")
...
...
PLT.savefig(pdfOutput, format='pdf')
PLT.clf()
Thanks so much for any advise!
MJ
Mark Janikas
Product Developer
ESRI, Geoprocessing
380 New York St.
Redlands, CA 92373
909-793-2853 (2563)
mja...@es...<mailto:mja...@es...>
From: Uri L. <las...@mi...> - 2011年02月24日 04:09:30
Hi all,
I am interested in jittering points in a plot. I searched the forum, but I
am amazed at the dearth of results on the topic. I am referring to
something like this:
http://goo.gl/Db47s
or
http://goo.gl/BjIZt
Is there a standard way people do this with MPL?
Thanks!
Uri
...................................................................................
Uri Laserson
Graduate Student, Biomedical Engineering
Harvard-MIT Division of Health Sciences and Technology
M +1 917 742 8019
las...@mi...
From: Jack S. <jac...@gm...> - 2011年02月24日 00:56:53
Hi everyone!
Is there any backend-independent way to get and set the figure window
coordinates and sizes (i.e. in pixels)? Currently when I make new plots they
appear in random locations as determined by my operating system; during
analysis when I'm making and destroying a lot of plot windows I want to be
able to have them automatically appear in "good" locations (such as the
upper left corner of my screen).
Also, I am trying to find ways to get/set the z-order.
Thanks in advance,
Jack
From: Benjamin R. <ben...@ou...> - 2011年02月24日 00:28:27
On Wed, Feb 23, 2011 at 4:52 PM, Rene Breton <sup...@gm...>wrote:
> Thanks much for the quick answer Ben!
>
> At least now I know it doesn't exist, yet. I might dig into the source
> code to change the color as you suggest. As a workaround, maybe I will
> simply tweak the .ps output in Adobe Illustrator; should be easy enough
> to remove such thing.
>
Another issue may be the tickmarks, which are made separately in another
segment of code.
>
> By the way, I'm very glad you (and people) took over the mplot3d. I
> really think that 3D plotting was the number one missing thing in
> Matplotlib and Python more generally. (mayavi2 is way to complicated and
> clunky for what most people need)
>
>
Thank you for your vote of confidence. This is exactly the intent of
mplot3d, which is to allow for the possibility of basic 3d plotting features
without the need to go "all-in" to a major 3d plotting system. We are still
a long way from what I envision for mplot3d.
> If I may make another suggestion, besides getting more control over the
> axes spines, it would be to allow the axes rendering to "mix" multiple
> plot objects. Let's say one plots a sphere and a cylinder (like a rod)
> that goes through the sphere and get the part of the cylinder that lies
> inside the sphere to be hidden. Of course, I realize it might not be
> trivial to do, depending exactly how plots are rendered.
>
>
You are not the first to request this, and you will not be the last.
Unfortunately, it is an intractable problem that can never be completely
solved by the 2d rendering framework employed by matplotlib. If/When
matplotlib gains an opengl backend, this problem will be revisited.
Please do continue to feel free to continue commenting on mplot3d and how
you think it can be better. And, as always, patches are welcome!
Ben Root
From: Rene B. <sup...@gm...> - 2011年02月23日 22:54:55
Thanks much for the quick answer Ben!
At least now I know it doesn't exist, yet. I might dig into the source 
code to change the color as you suggest. As a workaround, maybe I will 
simply tweak the .ps output in Adobe Illustrator; should be easy enough 
to remove such thing.
By the way, I'm very glad you (and people) took over the mplot3d. I 
really think that 3D plotting was the number one missing thing in 
Matplotlib and Python more generally. (mayavi2 is way to complicated and 
clunky for what most people need)
If I may make another suggestion, besides getting more control over the 
axes spines, it would be to allow the axes rendering to "mix" multiple 
plot objects. Let's say one plots a sphere and a cylinder (like a rod) 
that goes through the sphere and get the part of the cylinder that lies 
inside the sphere to be hidden. Of course, I realize it might not be 
trivial to do, depending exactly how plots are rendered.
Cheers,
Rene
On 11-02-23 05:33 PM, Benjamin Root wrote:
> On Wed, Feb 23, 2011 at 4:19 PM, Rene Breton <sup...@gm...
> <mailto:sup...@gm...>> wrote:
>
> Hi all,
>
> I'm making a 3d plot using Axes3D (plot_surface) and I want to get rid
> of the 3d gray box that surrounds the object so that only the object
> shows up. Is there a way to do it? After creating my Axes3D instance, I
> can't find much else than methods to change the x,y,z labels and axis
> limits.
>
> I found a hack using myAXINFO to change the color of each "panel" but
> the axis line still remains there.
>
> Ideally, there would be methods to access the color, visibility, etc.,
> of these elements. Maybe it's somewhere I can't find them...
>
>
> Here's a code snippet derived from one of the website's examples:
>
> #############
> from mpl_toolkits.mplot3d import Axes3D
> from matplotlib import cm
> from matplotlib.ticker import LinearLocator, FixedLocator,
> FormatStrFormatter
> import matplotlib.pyplot as plt
> import numpy as np
>
> fig = plt.figure()
> ax = fig.gca(projection='3d')
> X = np.arange(-5, 5, 0.25)
> Y = np.arange(-5, 5, 0.25)
> X, Y = np.meshgrid(X, Y)
> R = np.sqrt(X**2 + Y**2)
> Z = np.sin(R)
> surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet,
> linewidth=0, antialiased=False)
> ax.set_zlim3d(-1.01, 1.01)
>
> # The following makes the panels white, but the axis line remains there
> myAXINFO = { 'x': {'i': 0, 'tickdir': 1, 'juggled': (1, 0, 2), 'color':
> (1.0, 1.0, 1.0, 1.0, 1.0)}, 'y': {'i': 1, 'tickdir': 0, 'juggled': (0,
> 1, 2), 'color': (1.0, 1.0, 1.0, 1.0, 1.0)}, 'z': {'i': 2, 'tickdir': 0,
> 'juggled': (0, 2, 1), 'color': (1.0, 1.0, 1.0, 1.0, 1.0)} }
> ax.w_zaxis._AXINFO = myAXINFO
> ax.w_yaxis._AXINFO = myAXINFO
> ax.w_xaxis._AXINFO = myAXINFO
>
> plt.show()
> #############
>
>
> Thanks!
>
>
> Rene
>
>
>
> Rene,
>
> Unfortunately, you have stumbled upon one of the ugliness of the mplot3d
> implementation. I am hoping to have more control available for the next
> release. But right now, there is no way to turn off the axes spines
> (because they aren't implemented as spines). If you really want to dig
> into the source code, you could change the color argument to the Line2D
> call in the init3d() method in matplotlib/lib/mpl_toolkits/axis3d.py
>
> I am sorry I can not be more helpful.
> Ben Root
>
From: Benjamin R. <ben...@ou...> - 2011年02月23日 22:34:08
On Wed, Feb 23, 2011 at 4:19 PM, Rene Breton <sup...@gm...>wrote:
> Hi all,
>
> I'm making a 3d plot using Axes3D (plot_surface) and I want to get rid
> of the 3d gray box that surrounds the object so that only the object
> shows up. Is there a way to do it? After creating my Axes3D instance, I
> can't find much else than methods to change the x,y,z labels and axis
> limits.
>
> I found a hack using myAXINFO to change the color of each "panel" but
> the axis line still remains there.
>
> Ideally, there would be methods to access the color, visibility, etc.,
> of these elements. Maybe it's somewhere I can't find them...
>
>
> Here's a code snippet derived from one of the website's examples:
>
> #############
> from mpl_toolkits.mplot3d import Axes3D
> from matplotlib import cm
> from matplotlib.ticker import LinearLocator, FixedLocator,
> FormatStrFormatter
> import matplotlib.pyplot as plt
> import numpy as np
>
> fig = plt.figure()
> ax = fig.gca(projection='3d')
> X = np.arange(-5, 5, 0.25)
> Y = np.arange(-5, 5, 0.25)
> X, Y = np.meshgrid(X, Y)
> R = np.sqrt(X**2 + Y**2)
> Z = np.sin(R)
> surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet,
> linewidth=0, antialiased=False)
> ax.set_zlim3d(-1.01, 1.01)
>
> # The following makes the panels white, but the axis line remains there
> myAXINFO = { 'x': {'i': 0, 'tickdir': 1, 'juggled': (1, 0, 2), 'color':
> (1.0, 1.0, 1.0, 1.0, 1.0)}, 'y': {'i': 1, 'tickdir': 0, 'juggled': (0,
> 1, 2), 'color': (1.0, 1.0, 1.0, 1.0, 1.0)}, 'z': {'i': 2, 'tickdir': 0,
> 'juggled': (0, 2, 1), 'color': (1.0, 1.0, 1.0, 1.0, 1.0)} }
> ax.w_zaxis._AXINFO = myAXINFO
> ax.w_yaxis._AXINFO = myAXINFO
> ax.w_xaxis._AXINFO = myAXINFO
>
> plt.show()
> #############
>
>
> Thanks!
>
>
> Rene
>
>
>
Rene,
Unfortunately, you have stumbled upon one of the ugliness of the mplot3d
implementation. I am hoping to have more control available for the next
release. But right now, there is no way to turn off the axes spines
(because they aren't implemented as spines). If you really want to dig into
the source code, you could change the color argument to the Line2D call in
the init3d() method in matplotlib/lib/mpl_toolkits/axis3d.py
I am sorry I can not be more helpful.
Ben Root
From: Rene B. <sup...@gm...> - 2011年02月23日 22:21:13
Hi all,
I'm making a 3d plot using Axes3D (plot_surface) and I want to get rid 
of the 3d gray box that surrounds the object so that only the object 
shows up. Is there a way to do it? After creating my Axes3D instance, I 
can't find much else than methods to change the x,y,z labels and axis 
limits.
I found a hack using myAXINFO to change the color of each "panel" but 
the axis line still remains there.
Ideally, there would be methods to access the color, visibility, etc., 
of these elements. Maybe it's somewhere I can't find them...
Here's a code snippet derived from one of the website's examples:
#############
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FixedLocator, 
FormatStrFormatter
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.gca(projection='3d')
X = np.arange(-5, 5, 0.25)
Y = np.arange(-5, 5, 0.25)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X**2 + Y**2)
Z = np.sin(R)
surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet,
 linewidth=0, antialiased=False)
ax.set_zlim3d(-1.01, 1.01)
# The following makes the panels white, but the axis line remains there
myAXINFO = { 'x': {'i': 0, 'tickdir': 1, 'juggled': (1, 0, 2), 'color': 
(1.0, 1.0, 1.0, 1.0, 1.0)}, 'y': {'i': 1, 'tickdir': 0, 'juggled': (0, 
1, 2), 'color': (1.0, 1.0, 1.0, 1.0, 1.0)}, 'z': {'i': 2, 'tickdir': 0, 
'juggled': (0, 2, 1), 'color': (1.0, 1.0, 1.0, 1.0, 1.0)} }
ax.w_zaxis._AXINFO = myAXINFO
ax.w_yaxis._AXINFO = myAXINFO
ax.w_xaxis._AXINFO = myAXINFO
plt.show()
#############
Thanks!
Rene
From: Benjamin R. <ben...@ou...> - 2011年02月23日 21:16:57
On Wed, Feb 23, 2011 at 2:09 PM, bhargav vaidya <coo...@gm...> wrote:
> Hello Matplotlib Users.
>
> I am trying to work my way out to interpolate a surface from polar
> coordinates (R,Theta,Z) to rectangular co-ordinates(X,Y,Z)
> Basically I am looking for an equivalent for POLAR_SURFACE.pro routine in
> IDL using matplotlib/Scipy?
>
> http://idlastro.gsfc.nasa.gov/idl_html_help/POLAR_SURFACE.html
>
> Does anyone of you have done that before or could tell me what functions
> can I use to get that?
>
> Regards
> Bhargav Vaidya
>
>
(Quick Note: technically, you have cylindrical coordinates because you have
Z, not Phi)
While I am sure there are some more optimal methods, the straight-forward
way is to do something like the following:
import numpy as np
from scipy.interpolate import griddata
orig_x = R*np.cos(Theta)
orig_y = R*np.sin(Theta)
orig_z = Z
grid_x, grid_y, grid_z = np.mgrid[orig_x.min():orig_x.max():10j,
orig_y.min():orig_y.max():10j,
orig_z.min():orig_z.max():10j]
new_vals = griddata((orig_x, orig_y, orig_z), orig_vals, (grid_x, grid_y,
grid_z)
After running this, you should have new_vals which should have the same
shape as grid_x. You can also specify the interpolation method used by
griddata through the 'method' keyword argument. The '10j' in the np.mgrid[]
call merely specifies the number of points you want in that axis and can be
changed to any other integer you want (just keep the 'j' there to make it
work the way we want).
I hope that helps!
Ben Root
From: johanngoetz <jg...@uc...> - 2011年02月23日 20:49:42
There have been a lot of messages lately about histograms in general and I
though it was about time I share a bit of code I am using to handle them. I
have created a Histogram class that inherits directly from the numpy.ndarray
object. I then have a plothist() method which creates the plot on a canvas.
For 1D histograms, I create the PathPatch (Polygon) fom a series of points.
This is so that the histogram can be a single patch with a facecolor and an
edgecolor, though I usually have the edgecolor set to None. For 2D
histograms I use imshow() with interpolation='nearest'. This gives
rectangular bins which I prefer (over the hexbin) since typically, the
resolution of the x and y axes are different for me. I'm relatively new to
python so the code may be improved, but so far, it has worked quite nicely
for me. Hopefully it will work for someone else! And of course, if anyone
has any comments or suggestions, please let me know!
All definitions are in histogram.py. Put the test.py file in the same
directory and run test.py to make sure everything works.
http://old.nabble.com/file/p30998708/histogram.py histogram.py 
http://old.nabble.com/file/p30998708/test.py test.py 
Running test.py should give you several histogram figures including these:
http://old.nabble.com/file/p30998708/1dhist_color.png 
http://old.nabble.com/file/p30998708/2dhist_zeroed_colorbar.png 
-- 
View this message in context: http://old.nabble.com/1D-and-2D-histograms-using-numpy-and-matplotlib-tp30998708p30998708.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: bhargav v. <coo...@gm...> - 2011年02月23日 20:09:40
Hello Matplotlib Users.
I am trying to work my way out to interpolate a surface from polar coordinates (R,Theta,Z) to rectangular co-ordinates(X,Y,Z) 
Basically I am looking for an equivalent for POLAR_SURFACE.pro routine in IDL using matplotlib/Scipy?
http://idlastro.gsfc.nasa.gov/idl_html_help/POLAR_SURFACE.html
Does anyone of you have done that before or could tell me what functions can I use to get that?
Regards
Bhargav Vaidya
From: Jason S. <sto...@gm...> - 2011年02月23日 16:31:17
Michael,
I can get that to work rather easily on a matplotlib.pyplot figure via a
patch. I haven't had any luck getting that to work when using the
MatplotlibWidget in Qt.
Essentially in my code, I'm doing the following (where fig_myData is the
MatplotlibWidget instance):
 result = self.ui.fig_myData.axes.imshow(self.myData, cmap='jet',
interpolation='nearest', origin='lower', aspect='auto')
 self.ui.fig_myData.draw()
What do I put in before the draw() statement? Something like
self.ui.fig_myData.set_facecolor('#e0e0e0') ? I've tried that exact line
and the error I get is "MatplotlibWidget object has no attribute
'set_facecolor'".
Any ideas?
Thanks
On Fri, Feb 18, 2011 at 1:54 PM, Michael Droettboom <md...@st...> wrote:
> I think you'll need to manually set the color of the figure. I.e., given
> a figure object "fig":
>
> fig.set_facecolor(...whatever Qt API gives you the default background
> color...)
>
> You could also experiment with
>
> fig.set_frameon(False)
>
> which will not draw a background rectangle at all for the figure -- but
> that could cause overdrawing problems (possibly, haven't tried it).
>
> Mike
>
>
> On 02/18/2011 02:26 PM, Jason Stone wrote:
>
> Good afternoon all,
> I'm developing a GUI using QT Designer 4 and Python 2.7. The GUI will need
> to have several plots on it in order to show the data in the ways that I
> need. To accomplish this I'm using the matplotlib widget from within QT
> Designer. It all seems to work great, but I can't seem to find a way to
> change the background color of the widget. Essentially, I've got a nicely
> laid out GUI with the default QT Designer light gray as the "background
> color". Then I've got these matplotlib widgets which by default have a
> darker shade of gray/charcoal as their "background color". How do I change
> the matplotlib widget bgcolor to the default light gray so as to match the
> rest of the GUI? Turning the background of the main GUI to the dark gray to
> match the matplotlib color is not an option. I kind of assumed the issue
> has to do with the matplotlib widget and not with QT Designer, hence the
> reason for posting in this mailing list.
>
> Does anyone have any thoughts regarding this? Or can you point me to a
> documentation set that shows how to do this?
>
>
> ------------------------------------------------------------------------------
> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
> Pinpoint memory and threading errors before they happen.
> Find and fix more than 250 security defects in the development cycle.
> Locate bottlenecks in serial and parallel code that limit performance.http://p.sf.net/sfu/intel-dev2devfeb
>
>
> _______________________________________________
> Matplotlib-users mailing lis...@li...https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
>
> ------------------------------------------------------------------------------
> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
> Pinpoint memory and threading errors before they happen.
> Find and fix more than 250 security defects in the development cycle.
> Locate bottlenecks in serial and parallel code that limit performance.
> http://p.sf.net/sfu/intel-dev2devfeb
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
14 messages has been excluded from this view by a project administrator.

Showing results of 399

<< < 1 2 3 4 .. 16 > >> (Page 2 of 16)
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /