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



Showing 5 results of 5

From: Brian Z. <br...@gm...> - 2010年03月13日 23:49:54
I've done this successfully with both the Qt4 and WX Agg backends. The part
you care about is the update method.
Here's the snippet I use for Qt. It shouldn't change except for your
imports at the top if you're using Wx. Note, I've trimmed this down a bit,
so hopefully I didn't trim out anything important:
from matplotlib.figure import Figure
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as
FigureCanvas
class PlotWidget(QWidget):
 def __init__(self, parent):
 QWidget.__init__(self, parent)
 self.dpi=72
 self.figure = Figure(dpi=self.dpi, linewidth=3)
 self.canvas = FigureCanvas(self.figure)
 self.canvas.setParent(self)
 self.ax = self.figure.add_subplot(111)
 (self.__times, self.__temps) = ([], [])
 self.background = self.canvas.copy_from_bbox(self.ax.bbox)
 self.plotting_line = self.ax.plot([], color='red', lw=2)[0]
 def update(self, temp, secs):
 try:
 self.__times.append(secs)
 self.__temps.append(temp)
 self.canvas.restore_region(self.background)
 self.plotting_line.set_xdata(self.__times)
 self.plotting_line.set_ydata(self.__temps)
 self.ax.draw_artist(self.plotting_line)
 self.canvas.blit(self.ax.bbox)
 except IndexError:
 pass
 self.canvas.draw()
On Fri, Mar 12, 2010 at 12:36 PM, Gökhan Sever <gok...@gm...>wrote:
> Hello,
>
> I read a simple data stream from my computers serial port. I can nicely
> read the data using pyserial library but couldn't get it *nicely* working
> neither with WXAgg nor Qt4Agg using the following code. Although with WX I
> could get updated looks, the figure isn't very responsive in this way. I
> have looked at simple_idle_wx example but for some reason I can't make it
> work to update the canvas whenever the condition satisfied.
>
> What is the trick to make the real-time data plotted on the screen easily
> without blocking the figure itself?
>
> import serial
> import matplotlib.pyplot as plt
> plt.ion()
>
> ser = serial.Serial(0)
>
> conc = []
> while True:
> s = ser.readline()
> if s.startswith('CONC'):
> conc.append(float(s.split()[2]))
> plt.plot(conc)
> plt.show()
> plt.clf()
>
> ser.close()
>
> --
> Gökhan
>
>
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: Jae-Joon L. <lee...@gm...> - 2010年03月13日 20:02:41
On Fri, Mar 12, 2010 at 7:45 AM, othererik <oth...@gm...> wrote:
> Here's a short example that does the opposite of what I'm looking for.  The
> goal is to take a the polygon "poly_patch" and "cut" regions out of it.
> All I've managed to achieve so far has been to show regions of the
> "poly_patch".
>
With clip_path set, things inside the clip_path is only drawn. So, I
think you're misusing clip_path.
To draw a rectangle with a hole in it, you need to create a compound
path. And, this requires some understanding of how path system works
in general.
See this,
http://matplotlib.sourceforge.net/users/path_tutorial.html
and
http://old.nabble.com/Compound-paths-to19278422.html#a19296862
Here is modified version of your script that draws a rectangle with a
hole. It concatenates two existing paths. But, often it is better to
start from scratch (but again you need to understand how path works).
And of course, the resulting compound path can be set as a clip_path
of other artist.
Regards,
-JJ
import matplotlib
from matplotlib import patches
import pylab
fig=pylab.figure()
ax=fig.add_subplot(111)
# background line
line = ax.plot( [ 1, 2, 3], [ 1, 2, 3 ] )
# mask polygon that should cover/hide the area not intersecting the
poly_patch = patches.Polygon(((1,1),(1,3),(3,3), (3,1)))
# part I would like to see through
hole_patch = patches.Circle((2,2), radius=.5, facecolor='red')
from matplotlib.bezier import make_path_regular, concatenate_paths
from matplotlib.path import Path
from matplotlib.patches import PathPatch
poly_path = make_path_regular(poly_patch.get_path())
# close the path
closed_polygon_path = Path(list(poly_path.vertices)+[(0,0)],
 list(poly_path.codes)+[Path.CLOSEPOLY])
# circle with coordinate transformed
hole_path = hole_patch.get_path()
hole_path_transformed =
hole_patch.get_patch_transform().transform_path(hole_path)
# make polygon with a hole
poly_with_hole_path = concatenate_paths([closed_polygon_path,
 hole_path_transformed])
poly_with_hole_patch = PathPatch(poly_with_hole_path)
ax.add_patch(poly_with_hole_patch)
ax.set_xlim(0, 4)
ax.set_ylim(0, 4)
pylab.show()
David Smith wrote:
> This is a bug report.
> 
> I am using matplotlib 0.99.1 on Windows. When using contour with the 
> keyword
> argument locator=ticker.FixedLocator(levels), the plot is always 
> dropping the first
> and last contour level. If there are less than 3 levels, contour.py 
> throws an
> exception.
> 
> My workaround is to duplicate the first and last levels when using the 
> fixed locator: 
> e.g. my argument becomes
> 
> locator=FixedLocator( [levels[0]] + levels + [levels[-1]] )
> 
> I have traced the problem to the last line in contour.py, method 
> _autolev() which
> strips the first and last levels if the contours are not filled:
> 
> return lev[1:-1]
> 
> This line occurs at line 682 in my version of contour.py which came with 
> the 0.991 installation.
> 
> I realize that I could specify the levels in the argument V and this 
> does work. However
> this code is embedded in GUI-ness which allows the user to choose how 
> the contours
> are selected. Passing the locator seems to be the best option code-wise.
I committed a small change to svn trunk (r8190) that I think will handle 
your use case without fouling anything else up.
Eric
> 
> Thank you,
> 
> Dave Smith
> 
From: Jae-Joon L. <lee...@gm...> - 2010年03月13日 14:47:21
On Fri, Mar 12, 2010 at 11:11 AM, jdidion <jd...@em...> wrote:
> but I
> can't figure out how to make this happen, other than to use a really fat
> line width (which I would prefer not to do)
What other way do you have in mind? I don't see any.
By the way, why not just use histogram?
Regards,
-JJ
From: Ryan M. <rm...@gm...> - 2010年03月13日 01:47:21
On Fri, Mar 12, 2010 at 1:15 PM, Alex S <sch...@gm...> wrote:
> Hi there, does anyone know if there's a simple way to set an axis limit to a
> date? "viewlim_to_dt()" looks promising, but I can't figure out how to use
> it...
If you've plotted using dates, just use dates for the limits:
import matplotlib.pyplot as plt
import numpy as np
from datetime import datetime, timedelta
s = datetime.now()
x = np.array([s, s + timedelta(hours=3)])
y = np.arange(1,3)
plt.plot(x,y)
plt.xlim(s - timedelta(minutes=30), s + timedelta(hours=4))
plt.show()
Ryan
-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

Showing 5 results of 5

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