8000 Merge branch 'master' of https://github.com/matplotlib/matplotlib · matplotlib/matplotlib@e56c4e9 · GitHub
[go: up one dir, main page]

Skip to content

Commit e56c4e9

Browse files
committed
2 parents 960377d + ed5253d commit e56c4e9

File tree

19 files changed

+139
-68
lines changed

19 files changed

+139
-68
lines changed

doc/_templates/index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ <h4>Need help?</h4>
131131
the <a href="{{ pathto('api/index') }}">api</a> docs,
132132
<a href="http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html">mailing
133133
list archives</a>, and join the matplotlib
134-
mailing <a href="http://sourceforge.net/mail/?group_id=80706">lists</a>.
134+
mailing lists <a href="https://mail.python.org/mailman/listinfo/matplotlib-users">Users</a>,
135+
<a href="https://mail.python.org/mailman/listinfo/matplotlib-announce">Announce</a> and
136+
<a href="https://mail.python.org/mailman/listinfo/matplotlib-devel">Devel</a>.
135137
Check out the matplotlib questions
136138
on <a href="http://stackoverflow.com/questions/tagged/matplotlib">stackoverflow</a>.
137139
The <a href="{{ pathto('search') }}">search</a> tool searches all of

doc/devel/gitwash/this_project.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
.. _matplotlib: http://matplotlib.org
33
.. _`matplotlib github`: http://github.com/matplotlib/matplotlib
44

5-
.. _`matplotlib mailing list`: https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
5+
.. _`matplotlib mailing list`: https://mail.python.org/mailman/listinfo/matplotlib-devel

doc/faq/howto_faq.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ Request a new feature
503503

504504
Is there a feature you wish matplotlib had? Then ask! The best
505505
way to get started is to email the developer `mailing
506-
list <matplotlib-devel@lists.sourceforge.net>`_ for discussion.
506+
list <matplotlib-devel@python.org>`_ for discussion.
507507
This is an open source project developed primarily in the
508508
contributors free time, so there is no guarantee that your
509509
feature will be added. The *best* way to get the feature
@@ -526,7 +526,7 @@ demonstrating what the bug is. Including a clear, easy to test
526526
example makes it easy for the developers to evaluate the bug. Expect
527527
that the bug reports will be a conversation. If you do not want to
528528
register with github, please email bug reports to the `mailing list
529-
<matplotlib-devel@lists.sourceforge.net>`_.
529+
<matplotlib-devel@python.org>`_.
530530

531531

532532
The easiest way to submit patches to matplotlib is through pull

doc/faq/troubleshooting_faq.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ There is a good chance your question has already been asked:
9292
If you are unable to find an answer to your question through search,
9393
please provide the following information in your e-mail to the
9494
`mailing list
95-
<http://lists.sourceforge.net/mailman/listinfo/matplotlib-users>`_:
95+
<https://mail.python.org/mailman/listinfo/matplotlib-users>`_:
9696

9797
* your operating system; (Linux/UNIX users: post the output of ``uname -a``)
9898

doc/glossary/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Glossary
8484

8585

8686
pytz
87-
`pytz <http://pytz.sourceforge.net/>`_ provides the Olson tz
87+
`pytz <http://pythonhosted.org/pytz/>`_ provides the Olson tz
8888
database in Python. it allows accurate and cross platform
8989
timezone calculations and solves the issue of ambiguous times at
9090
the end of daylight savings

doc/users/screenshots.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ Mathtext_examples
252252

253253
Below is a sampling of the many TeX expressions now supported by matplotlib's
254254
internal mathtext engine. The mathtext module provides TeX style mathematical
255-
expressions using `freetype2 <http://freetype.sourceforge.net/index2.html>`_
255+
expressions using `freetype2 <http://www.freetype.org/>`_
256256
and the BaKoMa computer modern or `STIX <http://www.stixfonts.org>`_ fonts.
257257
See the :mod:`matplotlib.mathtext` module for additional details.
258258

doc/users/text_intro.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ expressions, truetype support for raster and vector outputs, newline
88
separated text with arbitrary rotations, and unicode support. Because
99
we embed the fonts directly in the output documents, e.g., for postscript
1010
or PDF, what you see on the screen is what you get in the hardcopy.
11-
`freetype2 <http://freetype.sourceforge.net/index2.html>`_ support
11+
`freetype2 <http://www.freetype.org/>`_ support
1212
produces very nice, antialiased fonts, that look good even at small
1313
raster sizes. matplotlib includes its own
1414
:mod:`matplotlib.font_manager`, thanks to Paul Barrett, which

examples/event_handling/README.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,3 @@ events are aware of things like data coordinate space and whih axes
99
the event occurs in so you don't have to mess with low level
1010
transformation details to go from canvas space to data space. Object
1111
picking examples are also included.
12-
13-
There is an event handling tutorial at
14-
http://matplotlib.sourceforge.net/pycon/event_handling_tut.pdf. The
15-
ReST source for this document is included in the matplotlib source
16-
distribution.
17-
18-

examples/pylab_examples/system_monitor.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ def get_net():
2121
def get_stats():
2222
return get_memory(), get_cpu(), get_net()
2323

24-
25-
# turn interactive mode on for dynamic updates. If you aren't in
26-
# interactive mode, you'll need to use a GUI event handler/timer.
27-
plt.ion()
28-
2924
fig, ax = plt.subplots()
3025
ind = np.arange(1, 4)
26+
27+
# show the figure, but do not block
28+
plt.show(block=False)
29+
30+
3131
pm, pc, pn = plt.bar(ind, get_stats())
3232
centers = ind + 0.5*pm.get_width()
3333
pm.set_facecolor('r')
@@ -44,10 +44,21 @@ def get_stats():
4444
for i in range(200): # run for a little while
4545
m, c, n = get_stats()
4646

47+
# update the animated artists
4748
pm.set_height(m)
4849
pc.set_height(c)
4950
pn.set_height(n)
51+
52+
# ask the canvas to re-draw itself the next time it
53+
# has a chance.
54+
# For most of the GUI backends this adds an event to the queue
55+
# of the GUI frameworks event loop.
56+
fig.canvas.draw_idle()
5057
try:
58+
# make sure that the GUI framework has a chance to run its event loop
59+
# and clear any GUI events. This needs to be in a try/except block
60+
# because the default implemenation of this method is to raise
61+
# NotImplementedError
5162
fig.canvas.flush_events()
5263
except NotImplementedError:
5364
pass

lib/matplotlib/animation.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,17 +1030,18 @@ def __init__(self, fig, artists, *args, **kwargs):
10301030

10311031
def _init_draw(self):
10321032
# Make all the artists involved in *any* frame invisible
1033-
axes = []
1033+
figs = set()
10341034
for f in self.new_frame_seq():
10351035
for artist in f:
10361036
artist.set_visible(False)
1037+
artist.set_animated(self._blit)
10371038
# Assemble a list of unique axes that need flushing
1038-
if artist.axes not in axes:
1039-
axes.append(artist.axes)
1039+
if artist.axes.figure not in figs:
1040+
figs.add(artist.axes.figure)
10401041

10411042
# Flush the needed axes
1042-
for ax in axes:
1043-
ax.figure.canvas.draw()
1043+
for fig in figs:
1044+
fig.canvas.draw()
10441045

10451046
def _pre_draw(self, framedata, blit):
10461047
'''
@@ -1155,6 +1156,8 @@ def _init_draw(self):
11551156
self._draw_frame(next(self.new_frame_seq()))
11561157
else:
11571158
self._drawn_artists = self._init_fun F438 c()
1159+
for a in self._drawn_artists:
1160+
a.set_animated(self._blit)
11581161

11591162
def _draw_frame(self, framedata):
11601163
# Save the data for potential saving of movies.
@@ -1167,3 +1170,5 @@ def _draw_frame(self, framedata):
11671170
# Call the func with framedata and args. If blitting is desired,
11681171
# func needs to return a sequence of any artists that were modified.
11691172
self._drawn_artists = self._func(framedata, *self._args)
1173+
for a in self._drawn_artists:
1174+
a.set_animated(self._blit)

lib/matplotlib/artist.py

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,9 @@ def draw_wrapper(artist, renderer, *args, **kwargs):
6868
return draw_wrapper
6969

7070

71-
def _stale_figure_callback(self):
72-
self.figure.stale = True
73-
74-
75-
def _stale_axes_callback(self):
76-
self.axes.stale = True
71+
def _stale_axes_callback(self, val):
72+
if self.axes:
73+
self.axes.stale = val
7774

7875

7976
class Artist(object):
@@ -87,6 +84,7 @@ class Artist(object):
8784

8885
def __init__(self):
8986
self._stale = True
87+
self.stale_callback = None
9088
self._axes = None
9189
self.figure = None
9290

@@ -124,6 +122,7 @@ def __getstate__(self):
124122
# remove the unpicklable remove method, this will get re-added on load
125123
# (by the axes) if the artist lives on an axes.
126124
d['_remove_method'] = None
125+
d['stale_callback'] = None
127126
return d
128127

129128
def remove(self):
@@ -222,7 +221,7 @@ def axes(self, new_axes):
222221

223222
self._axes = new_axes
224223
if new_axes is not None and new_axes is not self:
225-
self.add_callback(_stale_axes_callback)
224+
self.stale_callback = _stale_axes_callback
226225

227226
return new_axes
228227

@@ -236,15 +235,16 @@ def stale(self):
236235

237236
@stale.setter
238237
def stale(self, val):
239-
# only trigger call-back stack on being marked as 'stale'
240-
# when not already stale
241-
# the draw process will take care of propagating the cleaning
242-
# process
243-
if not (self._stale == val):
244-
self._stale = val
245-
# only trigger propagation if marking as stale
246-
if self._stale:
247-
self.pchanged()
238+
self._stale = val
239+
240+
# if the artist is animated it does not take normal part in the
241+
# draw stack and is not expected to be drawn as part of the normal
242+
# draw loop (when not saving) so do not propagate this change
243+
if self.get_animated():
244+
return
245+
246+
if val and self.stale_callback is not None:
247+
self.stale_callback(self, val)
248248

249249
def get_window_extent(self, renderer):
250250
"""
@@ -608,9 +608,19 @@ def set_figure(self, fig):
608608
609609
ACCEPTS: a :class:`matplotlib.figure.Figure` instance
610610
"""
611+
# if this is a no-op just return
612+
if self.figure is fig:
613+
return
614+
# if we currently have a figure (the case of both `self.figure`
615+
# and `fig` being none is taken care of above) we then user is
616+
# trying to change the figure an artist is associated with which
617+
# is not allowed for the same reason as adding the same instance
618+
# to more than one Axes
619+
if self.figure is not None:
620+
raise RuntimeError("Can not put single artist in "
621+
"more than one figure")
611622
self.figure = fig
612623
if self.figure and self.figure is not self:
613-
self.add_callback(_stale_figure_callback)
614624
self.pchanged()
615625
self.stale = True
616626

@@ -804,9 +814,9 @@ def set_animated(self, b):
804814
805815
ACCEPTS: [True | False]
806816
"""
807-
self._animated = b
808-
self.pchanged()
809-
self.stale = True
817+
if self._animated != b:
818+
self._animated = b
819+
self.pchanged()
810820

811821
def update(self, props):
812822
"""

lib/matplotlib/axes/_base.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ def __setstate__(self, state):
475475
container = getattr(self, container_name)
476476
for artist in container:
477477
artist._remove_method = container.remove
478-
self.stale = True
478+
self._stale = True
479479

480480
def get_window_extent(self, *args, **kwargs):
481481
"""
@@ -2059,7 +2059,8 @@ def draw(self, renderer=None, inframe=False):
20592059
if not self.get_visible():
20602060
return
20612061
renderer.open_group('axes')
2062-
2062+
# prevent triggering call backs during the draw process
2063+
self._stale = True
20632064
locator = self.get_axes_locator()
20642065
if locator:
20652066
pos = locator(self, renderer)

lib/matplotlib/backend_bases.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
from __future__ import (absolute_import, division, print_function,
3636
unicode_literals)
37+
from contextlib import contextmanager
3738

3839
from matplotlib.externals import six
3940
from matplotlib.externals.six.moves import xrange
@@ -1690,6 +1691,13 @@ def __init__(self, figure):
16901691
self.mouse_grabber = None # the axes currently grabbing mouse
16911692
self.toolbar = None # NavigationToolbar2 will set me
16921693
self._is_saving = False
1694+
self._is_idle_drawing = False
1695+
1696+
@contextmanager
1697+
def _idle_draw_cntx(self):
1698+
self._is_idle_drawing = True
1699+
yield
1700+
self._is_idle_drawing = False
16931701

16941702
def is_saving(self):
16951703
"""
@@ -2012,7 +2020,9 @@ def draw_idle(self, *args, **kwargs):
20122020
"""
20132021
:meth:`draw` only if idle; defaults to draw but backends can overrride
20142022
"""
2015-
self.draw(*args, **kwargs)
2023+
if not self._is_idle_drawing:
2024+
with self._idle_draw_cntx():
2025+
self.draw(*args, **kwargs)
20162026

20172027
def draw_cursor(self, event):
20182028
"""

lib/matplotlib/dates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
assumed. If you want to use a custom time zone, pass a
3838
:class:`pytz.timezone` instance with the tz keyword argument to
3939
:func:`num2date`, :func:`plot_date`, and any custom date tickers or
40-
locators you create. See `pytz <http://pytz.sourceforge.net>`_ for
40+
locators you create. See `pytz <http://pythonhosted.org/pytz/>`_ for
4141
information on :mod:`pytz` and timezone handling.
4242
4343
The `dateutil module <http://labix.org/python-dateutil>`_ provides

0 commit comments

Comments
 (0)
0