Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

use plt.subplots() in examples as much as possible#1458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
ivanov wants to merge2 commits intomatplotlib:masterfromivanov:use-subplots
Closed
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletionsCHANGELOG
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
2012-11-08 Replaced plt.figure and plt.subplot calls by the newer, more
convenient single call to plt.subplots() in the documentation
examples - PI

2012-10-05 Add support for saving animations as animated GIFs. - JVDP

2012-08-11 Fix path-closing bug in patches.Polygon, so that regardless
Expand Down
3 changes: 1 addition & 2 deletionsexamples/animation/animate_decay.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,8 +11,7 @@ def data_gen():
yield t, np.sin(2*np.pi*t) * np.exp(-t/10.)
data_gen.t = 0

fig = plt.figure()
ax = fig.add_subplot(111)
fig, ax = plt.subplots()
line, = ax.plot([], [], lw=2)
ax.set_ylim(-1.1, 1.1)
ax.set_xlim(0, 5)
Expand Down
3 changes: 1 addition & 2 deletionsexamples/animation/bayes_update.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,8 +39,7 @@ def __call__(self, i):
self.line.set_data(self.x, y)
return self.line,

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
fig, ax = plt.subplots()
ud = UpdateDist(ax, prob=0.7)
anim = FuncAnimation(fig, ud, frames=np.arange(100), init_func=ud.init,
interval=100, blit=True)
Expand Down
3 changes: 1 addition & 2 deletionsexamples/animation/histogram.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,8 +9,7 @@
import matplotlib.path as path
import matplotlib.animation as animation

fig = plt.figure()
ax = fig.add_subplot(111)
fig, ax = plt.subplots()

# histogram our data with numpy
data = np.random.randn(1000)
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,8 +10,7 @@ def data_gen():
return np.sin(2*np.pi*t) * np.exp(-t/10.)
data_gen.t = 0

fig = plt.figure()
ax = fig.add_subplot(111)
fig, ax = plt.subplots()
line, = ax.plot([], [], animated=True, lw=2)
ax.set_ylim(-1.1, 1.1)
ax.set_xlim(0, 5)
Expand Down
12 changes: 6 additions & 6 deletionsexamples/animation/old_animation/animation_blit_fltk.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@
import fltk
import matplotlib
matplotlib.use('FltkAgg')
importpylab asp
importmatplotlib.pyplot asplt
import numpy as npy
import time

Expand DownExpand Up@@ -42,13 +42,13 @@ def update(self,ptr):
sys.exit()
return True

ax =p.subplot(111)
p.subplots_adjust(left=0.3, bottom=0.3) # check for flipy bugs
p.grid() # to ensure proper background restore
fig,ax =plt.subplots()
plt.subplots_adjust(left=0.3, bottom=0.3) # check for flipy bugs
plt.grid() # to ensure proper background restore
# create the initial line
x = npy.arange(0,2*npy.pi,0.01)
line, =p.plot(x, npy.sin(x), animated=True)
p.draw()
line, =plt.plot(x, npy.sin(x), animated=True)
plt.draw()
anim=animator(ax)

fltk.Fl.add_idle(anim.update)
Expand Down
3 changes: 1 addition & 2 deletionsexamples/animation/old_animation/animation_blit_gtk.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,8 +16,7 @@
import matplotlib.pyplot as plt


fig = plt.figure()
ax = fig.add_subplot(111)
fig, ax = plt.subplots()
canvas = fig.canvas

fig.subplots_adjust(left=0.3, bottom=0.3) # check for flipy bugs
Expand Down
3 changes: 1 addition & 2 deletionsexamples/animation/old_animation/animation_blit_gtk2.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -148,9 +148,8 @@ def update_line(self, *args):


plt.rcParams["text.usetex"] = False
fig = plt.figure()

ax =fig.add_subplot(111)
fig,ax =plt.subplots()
ax.xaxis.set_animated(True)
ax.yaxis.set_animated(True)
canvas = fig.canvas
Expand Down
2 changes: 1 addition & 1 deletionexamples/animation/old_animation/animation_blit_qt.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ class BlitQT(QObject):
def __init__(self):
QObject.__init__(self, None, "app")

self.ax =p.subplot(111)
fig,self.ax =plt.subplots()
self.canvas = self.ax.figure.canvas
self.cnt = 0

Expand Down
14 changes: 7 additions & 7 deletionsexamples/animation/old_animation/animation_blit_tk.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,17 +7,17 @@
matplotlib.use('TkAgg')

import sys
importpylab asp
importmatplotlib.pyplot asplt
import numpy as npy
import time

ax =p.subplot(111)
fig,ax =plt.subplots()
canvas = ax.figure.canvas


# create the initial line
x = npy.arange(0,2*npy.pi,0.01)
line, =p.plot(x, npy.sin(x), animated=True, lw=2)
line, =plt.plot(x, npy.sin(x), animated=True, lw=2)

def run(*args):
background = canvas.copy_from_bbox(ax.bbox)
Expand All@@ -43,12 +43,12 @@ def run(*args):
run.cnt = 0


p.subplots_adjust(left=0.3, bottom=0.3) # check for flipy bugs
p.grid() # to ensure proper background restore
manager =p.get_current_fig_manager()
plt.subplots_adjust(left=0.3, bottom=0.3) # check for flipy bugs
plt.grid() # to ensure proper background restore
manager =plt.get_current_fig_manager()
manager.window.after(100, run)

p.show()
plt.show()



2 changes: 1 addition & 1 deletionexamples/animation/old_animation/animation_blit_wx.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@
matplotlib.backends.backend_wxagg._use_accelerator(False)


ax =p.subplot(111)
fig,ax =plt.subplots()
canvas = ax.figure.canvas


Expand Down
5 changes: 2 additions & 3 deletionsexamples/animation/old_animation/draggable_legend.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
import matplotlib.pyplot as plt


ax = plt.subplot(111)
fig, ax = plt.subplots()
ax.plot([1,2,3], label="test")

l = ax.legend()
d1 = l.draggable()

xy = 1, 2
xy = 1, 2
txt = ax.annotate("Test", xy, xytext=(-30, 30),
textcoords="offset points",
bbox=dict(boxstyle="round",fc=(0.2, 1, 1)),
Expand Down
3 changes: 1 addition & 2 deletionsexamples/animation/old_animation/gtk_timeout.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,8 +5,7 @@

import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111)
fig, ax = plt.subplots()
line, = ax.plot(np.random.rand(10))
ax.set_ylim(0, 1)

Expand Down
3 changes: 1 addition & 2 deletionsexamples/animation/old_animation/histogram_tkagg.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,8 +11,7 @@
import matplotlib.patches as patches
import matplotlib.path as path

fig = plt.figure()
ax = fig.add_subplot(111)
fig, ax = plt.subplots()

# histogram our data with numpy
data = np.random.randn(1000)
Expand Down
4 changes: 1 addition & 3 deletionsexamples/animation/old_animation/simple_anim_gtk.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,9 +9,7 @@

import matplotlib.pyplot as plt

fig = plt.figure()

ax = fig.add_subplot(111)
fig, ax = plt.subplots()

def animate():
tstart = time.time() # for profiling
Expand Down
3 changes: 1 addition & 2 deletionsexamples/animation/old_animation/simple_anim_tkagg.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,8 +10,7 @@
matplotlib.use('TkAgg') # do this before importing pylab

import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
fig, ax = plt.subplots()

def animate():
tstart = time.time() # for profiling
Expand Down
4 changes: 1 addition & 3 deletionsexamples/animation/old_animation/simple_idle_wx.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,9 +9,7 @@

import matplotlib.pyplot as plt

fig = plt.figure()

ax = fig.add_subplot(111)
fig, ax = plt.subplots()
t = np.arange(0, 2*np.pi, 0.1)
line, = ax.plot(t, np.sin(t))
dt = 0.05
Expand Down
4 changes: 1 addition & 3 deletionsexamples/animation/old_animation/simple_timer_wx.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,9 +9,7 @@

import matplotlib.pyplot as plt

fig = plt.figure()

ax = fig.add_subplot(111)
fig, ax = plt.subplots()
t = np.arange(0, 2*np.pi, 0.1)
line, = ax.plot(t, np.sin(t))
dt = 0.05
Expand Down
3 changes: 1 addition & 2 deletionsexamples/animation/old_animation/strip_chart_demo.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -64,8 +64,7 @@ def update(self, *args):

from pylab import figure, show

fig = figure()
ax = fig.add_subplot(111)
fig, ax = plt.subplots()
scope = Scope(ax)
gobject.idle_add(scope.update)

Expand Down
3 changes: 1 addition & 2 deletionsexamples/animation/random_data.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,8 +2,7 @@
import matplotlib.pyplot as plt
import matplotlib.animation as animation

fig = plt.figure()
ax = fig.add_subplot(111)
fig, ax = plt.subplots()
line, = ax.plot(np.random.rand(10))
ax.set_ylim(0, 1)

Expand Down
3 changes: 1 addition & 2 deletionsexamples/animation/simple_anim.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,8 +5,7 @@
import matplotlib.pyplot as plt
import matplotlib.animation as animation

fig = plt.figure()
ax = fig.add_subplot(111)
fig, ax = plt.subplots()

x = np.arange(0, 2*np.pi, 0.01) # x-array
line, = ax.plot(x, np.sin(x))
Expand Down
3 changes: 1 addition & 2 deletionsexamples/animation/strip_chart_demo.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,8 +44,7 @@ def emitter(p=0.03):
else:
yield np.random.rand(1)

fig = plt.figure()
ax = fig.add_subplot(111)
fig, ax = plt.subplots()
scope = Scope(ax)

# pass a generator in "emitter" to produce data for the update func
Expand Down
3 changes: 1 addition & 2 deletionsexamples/api/README.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,8 +29,7 @@ A simple example of the recommended style is::
import numpy as np
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111) # or add_axes
fig, ax = plt.subplots()
ax.plot(np.random.rand(10))
ax.set_xlabel('some x data')
ax.set_ylabel('some y data')
Expand Down
6 changes: 2 additions & 4 deletionsexamples/api/agg_oo.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,12 +6,10 @@
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure

fig = Figure()
canvas = FigureCanvas(fig)
ax = fig.add_subplot(111)
fig, ax = plt.subplots()
ax.plot([1,2,3])
ax.set_title('hi mom')
ax.grid(True)
ax.set_xlabel('time')
ax.set_ylabel('volts')
canvas.print_figure('test')
fig.canvas.print_figure('test')
3 changes: 1 addition & 2 deletionsexamples/api/barchart_demo.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,8 +11,7 @@
ind = np.arange(N) # the x locations for the groups
width = 0.35 # the width of the bars

fig = plt.figure()
ax = fig.add_subplot(111)
fig, ax = plt.subplots()
rects1 = ax.bar(ind, menMeans, width, color='r', yerr=menStd)

womenMeans = (25, 32, 34, 20, 25)
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp