|
From: <jd...@us...> - 2011-01-06 01:26:41
|
Revision: 8896
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8896&view=rev
Author: jdh2358
Date: 2011-01-06 01:26:35 +0000 (Thu, 06 Jan 2011)
Log Message:
-----------
fix the plot directive
Modified Paths:
--------------
trunk/matplotlib/examples/animation/dynamic_image2.py
trunk/matplotlib/examples/animation/strip_chart_demo.py
trunk/matplotlib/lib/matplotlib/figure.py
trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py
trunk/matplotlib/lib/matplotlib/tests/test_axes.py
Modified: trunk/matplotlib/examples/animation/dynamic_image2.py
===================================================================
--- trunk/matplotlib/examples/animation/dynamic_image2.py 2011-01-06 01:26:23 UTC (rev 8895)
+++ trunk/matplotlib/examples/animation/dynamic_image2.py 2011-01-06 01:26:35 UTC (rev 8896)
@@ -13,13 +13,20 @@
x = np.linspace(0, 2 * np.pi, 120)
y = np.linspace(0, 2 * np.pi, 100).reshape(-1, 1)
-
+# ims is a list of lists, each row is a list of artists to draw in the
+# current frame; here we are just animating one artist, the image, in
+# each frame
ims = []
for i in range(60):
x += np.pi / 15.
y += np.pi / 20.
- ims.append([plt.imshow(f(x, y), cmap=plt.get_cmap('jet'))])
+ im = plt.imshow(f(x, y))
+ ims.append([im])
ani = animation.ArtistAnimation(fig, ims, interval=50, blit=True,
repeat_delay=1000)
+
+ani.save('dynamic_images.mp4')
+
+
plt.show()
Modified: trunk/matplotlib/examples/animation/strip_chart_demo.py
===================================================================
--- trunk/matplotlib/examples/animation/strip_chart_demo.py 2011-01-06 01:26:23 UTC (rev 8895)
+++ trunk/matplotlib/examples/animation/strip_chart_demo.py 2011-01-06 01:26:35 UTC (rev 8896)
@@ -9,7 +9,7 @@
import matplotlib.animation as animation
class Scope:
- def __init__(self, ax, maxt=10, dt=0.01):
+ def __init__(self, ax, maxt=2, dt=0.02):
self.ax = ax
self.dt = dt
self.maxt = maxt
@@ -26,6 +26,7 @@
self.tdata = [self.tdata[-1]]
self.ydata = [self.ydata[-1]]
self.ax.set_xlim(self.tdata[0], self.tdata[0] + self.maxt)
+ self.ax.figure.canvas.draw()
t = self.tdata[-1] + self.dt
self.tdata.append(t)
@@ -33,7 +34,8 @@
self.line.set_data(self.tdata, self.ydata)
return self.line,
-def emitter(p=0.01):
+
+def emitter(p=0.03):
'return a random value with probability p, else 0'
while True:
v = np.random.rand(1)
@@ -45,6 +47,10 @@
fig = plt.figure()
ax = fig.add_subplot(111)
scope = Scope(ax)
+
+# pass a generator in "emitter" to produce data for the update func
ani = animation.FuncAnimation(fig, scope.update, emitter, interval=10,
blit=True)
+
+
plt.show()
Modified: trunk/matplotlib/lib/matplotlib/figure.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/figure.py 2011-01-06 01:26:23 UTC (rev 8895)
+++ trunk/matplotlib/lib/matplotlib/figure.py 2011-01-06 01:26:35 UTC (rev 8896)
@@ -807,7 +807,6 @@
Render the figure using :class:`matplotlib.backend_bases.RendererBase` instance renderer
"""
# draw the figure bounding box, perhaps none for white figure
- #print 'figure draw'
if not self.get_visible(): return
renderer.open_group('figure')
Modified: trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py 2011-01-06 01:26:23 UTC (rev 8895)
+++ trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py 2011-01-06 01:26:35 UTC (rev 8896)
@@ -265,7 +265,10 @@
def clear_state():
plt.close('all')
- matplotlib.rc_file_defaults()
+ matplotlib.rcdefaults()
+ # Set a default figure size that doesn't overflow typical browser
+ # windows. The script is free to override it if necessary.
+ matplotlib.rcParams['figure.figsize'] = (5.5, 4.5)
def render_figures(plot_path, function_name, plot_code, tmpdir, destdir,
formats, context=False):
Modified: trunk/matplotlib/lib/matplotlib/tests/test_axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/tests/test_axes.py 2011-01-06 01:26:23 UTC (rev 8895)
+++ trunk/matplotlib/lib/matplotlib/tests/test_axes.py 2011-01-06 01:26:35 UTC (rev 8896)
@@ -512,6 +512,13 @@
fig.savefig('pcolormesh')
+
+@image_comparison(baseline_images=['canonical'])
+def test_canonical():
+ fig, ax = plt.subplots()
+ ax.plot([1,2,3])
+ fig.savefig('canonical')
+
if __name__=='__main__':
import nose
nose.runmodule(argv=['-s','--with-doctest'], exit=False)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|