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
(1)
2
(8)
3
(10)
4
5
(4)
6
7
(5)
8
(6)
9
(4)
10
(12)
11
(7)
12
(2)
13
(2)
14
(5)
15
(9)
16
(4)
17
(7)
18
(2)
19
(12)
20
(8)
21
(11)
22
(11)
23
(2)
24
(18)
25
(18)
26
(6)
27
(7)
28
(10)
29
(7)
30
(31)
31
(10)

Showing 9 results of 9

From: Scott H. <st...@co...> - 2012年08月15日 15:37:06
Hello,
I'm trying to modify the following script to no avail:
http://matplotlib.github.com/examples/axes_grid/demo_colorbar_with_inset_locator.html
I'd like to have a white background behind the inset colorbar that 
adjusts automatically to figure resizing. I'm thinking of doing this by 
adding a Rectangle patch with the appropriate axes coordinates. What's 
the easiest way get those coordinates (sufficiently big to include the 
ticklabels) & draw the patch?
Thanks,
-- 
---------------
Scott T. Henderson
http://www.geo.cornell.edu/eas/gstudent/sth54/contact.html
From: David G. <da...@we...> - 2012年08月15日 13:30:32
I'm running:
Matplotlib 1.1.0
wxPython 2.9.2.4 osx-carbon (classic)
Python 2.6
on Mac OSX 10.6.8
On Aug 15, 2012, at 5:17 AM, Benjamin Root wrote:
> 
> 
> On Wednesday, August 15, 2012, David Grudoski wrote:
> Hi All,
> I've encountered this problem with the both NavigationToolbar2Wx and the NavigationToolbar2WxAgg.
> When I click the Zoom or Pan button the button disappears. The functionality is maintained so if a click the location that the button used to be displayed at the toggle action still works its just that the button is no longer displayed.
> Can any one help me fix this?
> Thanks
> David
> 
> Which version of matplotlib are you using?
> 
> Ben Root
From: mogliii <mo...@gm...> - 2012年08月15日 13:09:22
<html>
 <head>
 <meta content="text/html; charset=ISO-8859-1"
 http-equiv="Content-Type">
 </head>
 <body bgcolor="#FFFFFF" text="#000000">
 <div class="moz-cite-prefix">On 15/08/2012 09:56, Mogliii wrote:<br>
 </div>
 <blockquote cite="mid:502...@gm..." type="cite">
 <meta content="text/html; charset=ISO-8859-1"
 http-equiv="Content-Type">
 I get the attached result. The \texttt{} is rendered differently
 by matplotlib and latex.<br>
 <br>
 I am using the default latex fonts, and below is my preamble.<br>
 <br>
 <meta http-equiv="content-type" content="text/html;
 charset=ISO-8859-1">
 rc('font', **{'family':'serif', 'serif':['Computer Modern
 Roman']})<br>
 params = {'backend': 'pdf',<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'axes.labelsize': 12,<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'text.fontsize': 12,<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'legend.fontsize': 12,<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'xtick.labelsize': 10,<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'ytick.labelsize': 10,<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'text.usetex': True,<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'figure.figsize': fig_size,<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'axes.unicode_minus': True}<br>
 matplotlib.rcParams.update(params)<br>
 <br>
 <br>
 <br>
 What do I have to change to match the font?<br>
 </blockquote>
 Found the solution.<br>
 The default font of matplotlib is Courier, but LaTeX rendered with
 Computer Modern Typewriter<br>
 <br>
 Changing the first line makes matplotlib use the same font.<br>
 <pre class="lang-tex prettyprint"><code><span class="pln">rc</span><span class="pun">(</span><span class="pln">'font', **</span><span class="pun">{</span><span class="pln">'family':'serif', 'serif':</span><span class="pun">[</span><span class="pln">'Computer Modern Roman'</span><span class="pun">]</span><span class="pln">, 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'monospace': </span><span class="pun">[</span><span class="pln">'Computer Modern Typewriter'</span><span class="pun">]})</span></code></pre>
 </body>
</html>
From: Benjamin R. <ben...@ou...> - 2012年08月15日 12:17:17
On Wednesday, August 15, 2012, David Grudoski wrote:
> Hi All,
> I've encountered this problem with the both NavigationToolbar2Wx and the
> NavigationToolbar2WxAgg.
> When I click the Zoom or Pan button the button disappears. The
> functionality is maintained so if a click the location that the button used
> to be displayed at the toggle action still works its just that the button
> is no longer displayed.
> Can any one help me fix this?
> Thanks
> David
Which version of matplotlib are you using?
Ben Root
From: Jesper L. <jes...@gm...> - 2012年08月15日 09:40:23
Hi Matplotlib users
I have an application where performance is critical and matplotlib is
the performance bottleneck. I am making a lot of figures using the
same basic setup of the figure. And from my profiling I can see that
this basic setup accounts for most of the CPU time. Let us say that I
make a given figure including some axes. My questions are:
1. Can I make a copy of this figure including axes (copy.deepcopy does
not work on Figure objects) and use the copy for plotting on?
2. And how? Should I use the frozen method somehow?
I did do something similar some years back. But at the time I removed
the stuff I had drawn on the figure. I would like to avoid this for
two reasons: 1) Thread safety, I must be able to draw figures in
several simultaneous threads and 2) I really had to go into some
low-level details in matplotlib (not a show-stopper, but for
maintenance reasons I would like to keep the code as clear as
possible).
Best regards,
Jesper
From: Mogliii <mo...@gm...> - 2012年08月15日 08:57:00
Attachments: MPL_latex_fontdiff.png
I get the attached result. The \texttt{} is rendered differently by
matplotlib and latex.
I am using the default latex fonts, and below is my preamble.
rc('font', **{'family':'serif', 'serif':['Computer Modern Roman']})
params = {'backend': 'pdf',
 'axes.labelsize': 12,
 'text.fontsize': 12,
 'legend.fontsize': 12,
 'xtick.labelsize': 10,
 'ytick.labelsize': 10,
 'text.usetex': True,
 'figure.figsize': fig_size,
 'axes.unicode_minus': True}
matplotlib.rcParams.update(params)
What do I have to change to match the font?
From: David G. <da...@we...> - 2012年08月15日 06:16:01
Hi All,
I've encountered this problem with the both NavigationToolbar2Wx and the NavigationToolbar2WxAgg.
When I click the Zoom or Pan button the button disappears. The functionality is maintained so if a click the location that the button used to be displayed at the toggle action still works its just that the button is no longer displayed.
Can any one help me fix this?
Thanks 
David
Here's the code that demonstrated the problem"
######################################
##### Start of Code #################
######################################
#!/usr/bin/env python
# encoding: UTF-8
"""
Basic wxPython App w DrawPanel.py
"""
import sys
reload(sys) 
sys.setdefaultencoding("utf-8")
import os
import time
import numpy as np
import matplotlib
matplotlib.use('WXAgg')
from matplotlib.backends.backend_wxagg import Toolbar, FigureCanvasWxAgg
from matplotlib.figure import Figure
import pylab as plt
import wx
from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg
class DrawPanel(wx.Panel):
	""" This class constructs a Matplotlib figure and canvas to allow for plots. """
	def __init__(self, parent):
		wx.Panel.__init__(self, parent, -1)
		#Create the widgets
		self.figure = Figure(figsize=(1,1))
		self.canvas = FigureCanvasWxAgg(self, -1, self.figure)
		self.toolbar = NavigationToolbar2WxAgg(self.canvas)	
		sizer = wx.BoxSizer(wx.VERTICAL)
		# add to sizer allows resizing
		sizer.Add(self.toolbar, 0, wx.LEFT|wx.TOP)
		sizer.Add(self.canvas, 1, wx.LEFT|wx.TOP|wx.GROW)
		self.SetSizer(sizer)
		self.Fit()
		# plot some data
		self.x=np.arange(0,10,.1)
		self.y=plt.sin(self.x)
		self.init_plot()
		
	def init_plot(self):
		self.figure.clf()
		self.ax = self.figure.gca()
		self.ax.plot(self.x, self.y)
		self.canvas.draw()
########################################################################
class MainFrame(wx.Frame):
	"""This is the Main Frame"""
	#----------------------------------------------------------------------
	def __init__(self):
		"""Constructor"""
		wx.Frame.__init__(self, None, title="Basic wxPython App w DrawPanel",size=(800,600))
		# Create StatusBar
		self.sb=self.CreateStatusBar()
		self.SetStatusText('Basic wxPython App w DrawPanel')
		#------------------------------
		self.Freeze() # need this to prevent flicker during plot resize/redraw
		self.mainpanel = DrawPanel(self)
		self.Layout()
		self.Thaw()
		self.Show()
#----------------------------------------------------------------------
if __name__ == "__main__":
	app = wx.App(False)
	frame = MainFrame()
	app.MainLoop()
######################################
##### End of Code #################
######################################
From: Eric F. <ef...@ha...> - 2012年08月15日 02:11:14
On 2012年08月14日 3:15 PM, Damien Irving wrote:
> I've been plotting timeseries data using the matplotlib.dates module and
> have come across an issue when using it in conjunction with the subplot
> command.
>
> For figures with greater than one subplot in a particular column, the
> time (or x) axis ticks and their labels are only printed on the final
> subplot that is plotted, and are missing on all other subplots in that
> column (see example code below). The only exception is when the time
> axis is identical for each plot in the column (you can test this by
> editing my example code at ###) - then all time axis ticks and their
> labels are displayed correctly.
>
> Is this a bug in the subplot source code, or am I missing something?
You are missing something, but it is something that is quite 
non-intuitive and easy to miss: Locators can't be shared among axes. 
The set_major_locator() method assigns its axis to that Locator, 
overwriting any axis that was previously assigned.
The solution is to make a new Locator instance for each axis that needs one.
Eric
>
>
> from pylab import *
> from matplotlib.dates import YEARLY, DateFormatter, rrulewrapper,
> RRuleLocator, drange
> import datetime
>
> # tick every 5th easter #
> rule = rrulewrapper(YEARLY, byeaster=1, interval=5)
> loc = RRuleLocator(rule)
> formatter = DateFormatter('%m/%d/%y')
>
> # data for subplot 1 #
> date1 = datetime.date( 1952, 1, 1 )
> date2 = datetime.date( 2004, 4, 12 )
> delta = datetime.timedelta(days=100)
>
> dates = drange(date1, date2, delta)
> s = rand(len(dates)) # make up some random y values
>
> # plot subplot 1 #
> ax1 = subplot(211)
> plot_date(dates, s)
> ax1.xaxis.set_major_locator(loc)
> ax1.xaxis.set_major_formatter(formatter)
> labels = ax1.get_xticklabels()
> setp(labels, rotation=30, fontsize=10)
>
> # data for subplot 2 #
> date1 = datetime.date( 2052, 1, 1 ) ###( 1952, 1, 1 )
> date2 = datetime.date( 2104, 4, 12 ) ###( 2004, 4, 12 )
>
> dates = drange(date1, date2, delta)
> s = rand(len(dates)) # make up some random y values
>
> # plot subplot 2 #
> ax2 = subplot(212)
> plot_date(dates, s)
> ax2.xaxis.set_major_locator(loc)
> ax2.xaxis.set_major_formatter(formatter)
> labels = ax2.get_xticklabels()
> setp(labels, rotation=30, fontsize=10)
>
> show()
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Damien I. <dam...@ya...> - 2012年08月15日 01:28:05
I've been plotting timeseries data using the matplotlib.dates module and have come across an issue when using it in conjunction with the subplot command. 
For figures with greater than one subplot in a particular column, the time (or x) axis ticks and their labels are only printed on the final subplot that is plotted, and are missing on all other subplots in that column (see example code below). The only exception is when the time axis is identical for each plot in the column (you can test this by editing my example code at ###) - then all time axis ticks and their labels are displayed correctly.
Is this a bug in the subplot source code, or am I missing something?
from pylab import *
from matplotlib.dates import YEARLY, DateFormatter, rrulewrapper, RRuleLocator, drange
import datetime
# tick every 5th easter #
rule = rrulewrapper(YEARLY, byeaster=1, interval=5)
loc = RRuleLocator(rule)
formatter = DateFormatter('%m/%d/%y')
# data for subplot 1 #
date1 = datetime.date( 1952, 1, 1 )
date2 = datetime.date( 2004, 4, 12 )
delta = datetime.timedelta(days=100)
dates = drange(date1, date2, delta)
s = rand(len(dates)) # make up some random y values
# plot subplot 1 #
ax1 = subplot(211)
plot_date(dates, s)
ax1.xaxis.set_major_locator(loc)
ax1.xaxis.set_major_formatter(formatter)
labels = ax1.get_xticklabels()
setp(labels, rotation=30, fontsize=10)
# data for subplot 2 #
date1 = datetime.date( 2052, 1, 1 ) ###( 1952, 1, 1 ) 
date2 = datetime.date( 2104, 4, 12 ) ###( 2004, 4, 12 )
dates = drange(date1, date2, delta)
s = rand(len(dates)) # make up some random y values
# plot subplot 2 #
ax2 = subplot(212)
plot_date(dates, s)
ax2.xaxis.set_major_locator(loc)
ax2.xaxis.set_major_formatter(formatter)
labels = ax2.get_xticklabels()
setp(labels, rotation=30, fontsize=10)
show()

Showing 9 results of 9

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 によって変換されたページ (->オリジナル) /