Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
more subplots, cleanup of old import * style
  • Loading branch information
ivanov committed Nov 10, 2012
commit 9a31dbb63188a80c5c80a10ecada87f072b4857b
14 changes: 7 additions & 7 deletions examples/animation/old_animation/animation_blit_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from __future__ import print_function

import os, sys
import sys
import matplotlib
matplotlib.use('QtAgg') # qt3 example

Expand All @@ -16,21 +16,21 @@
FALSE = 0
ITERS = 1000

import pylab as p
import matplotlib.pyplot as plt
import numpy as npy
import time

class BlitQT(QObject):
def __init__(self):
QObject.__init__(self, None, "app")

fig, self.ax = plt.subplots()
self.ax = plt.axes()
self.canvas = self.ax.figure.canvas
self.cnt = 0

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

self.background = None

Expand All @@ -55,12 +55,12 @@ def timerEvent(self, evt):
else:
self.cnt += 1

p.subplots_adjust(left=0.3, bottom=0.3) # check for flipy bugs
p.grid() # to ensure proper background restore
plt.subplots_adjust(left=0.3, bottom=0.3) # check for flipy bugs
plt.grid() # to ensure proper background restore

app = BlitQT()
# for profiling
app.tstart = time.time()
app.startTimer(0)

p.show()
plt.show()
2 changes: 1 addition & 1 deletion examples/animation/old_animation/animation_blit_tk.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import time

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


# create the initial line
Expand Down
1 change: 1 addition & 0 deletions examples/animation/old_animation/animation_blit_wx.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import matplotlib
matplotlib.use('WXAgg')
matplotlib.rcParams['toolbar'] = 'None'
import matplotlib.pyplot as plt

import wx
import sys
Expand Down
1 change: 0 additions & 1 deletion examples/animation/old_animation/histogram_tkagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
This example shows how to use a path patch to draw a bunch of
rectangles for an animated histogram
"""
import time
import numpy as np
import matplotlib
matplotlib.use('TkAgg') # do this before importing pylab
Expand Down
1 change: 0 additions & 1 deletion examples/animation/old_animation/simple_idle_wx.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
A simple example of an animated plot using a wx backend
"""
from __future__ import print_function
import time
import numpy as np
import matplotlib
matplotlib.use('WXAgg') # do this before importing pylab
Expand Down
1 change: 0 additions & 1 deletion examples/animation/old_animation/simple_timer_wx.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""
A simple example of an animated plot using a wx backend
"""
import time
import numpy as np
import matplotlib
matplotlib.use('WXAgg') # do this before importing pylab
Expand Down
5 changes: 2 additions & 3 deletions examples/animation/old_animation/strip_chart_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import matplotlib
matplotlib.use('GTKAgg')
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D


Expand Down Expand Up @@ -62,10 +63,8 @@ def update(self, *args):
return True


from pylab import figure, show

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

show()
plt.show()
1 change: 0 additions & 1 deletion examples/animation/strip_chart_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Emulate an oscilloscope. Requires the animation API introduced in
matplotlib 1.0 SVN.
"""
import matplotlib
import numpy as np
from matplotlib.lines import Line2D
import matplotlib.pyplot as plt
Expand Down
1 change: 0 additions & 1 deletion examples/api/joinstyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"""

import numpy as np
import matplotlib
import matplotlib.pyplot as plt

def plot_angle(ax, x, y, angle, style):
Expand Down
1 change: 0 additions & 1 deletion examples/api/path_patch_demo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import numpy as np
import matplotlib.path as mpath
import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
Expand Down
1 change: 0 additions & 1 deletion examples/api/quad_bezier.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import numpy as np
import matplotlib.path as mpath
import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
Expand Down
1 change: 0 additions & 1 deletion examples/api/watermark_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""
from __future__ import print_function
import numpy as np
import matplotlib
import matplotlib.cbook as cbook
import matplotlib.image as image
import matplotlib.pyplot as plt
Expand Down
2 changes: 1 addition & 1 deletion examples/event_handling/path_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def pathpatch_changed(self, pathpatch):
'this method is called whenever the pathpatchgon object is called'
# only copy the artist props to the line (except visibility)
vis = self.line.get_visible()
Artist.update_from(self.line, pathpatch)
plt.Artist.update_from(self.line, pathpatch)
self.line.set_visible(vis) # don't use the pathpatch visibility state


Expand Down
7 changes: 3 additions & 4 deletions examples/pylab_examples/agg_buffer_to_array.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import matplotlib
from pylab import figure, show
import matplotlib.pyplot as plt
import numpy as np

# make an agg figure
Expand All @@ -17,7 +16,7 @@
X.shape = h,w,4

# now display the array X as an Axes in a new figure
fig2 = figure()
fig2 = plt.figure()
ax2 = fig2.add_subplot(111, frameon=False)
ax2.imshow(X)
show()
plt.show()
1 change: 0 additions & 1 deletion examples/pylab_examples/barchart_demo2.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import numpy as np
import matplotlib.pyplot as plt
import pylab
from matplotlib.patches import Polygon
from matplotlib.ticker import MaxNLocator


Expand Down
1 change: 0 additions & 1 deletion examples/pylab_examples/boxplot_demo3.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import matplotlib.pyplot as plt
import matplotlib.transforms as mtransforms
import numpy as np

def fakeBootStrapper(n):
Expand Down
2 changes: 0 additions & 2 deletions examples/pylab_examples/centered_ticklabels.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
# between the major ticks. Here is an example that labels the months,
# centered between the ticks

import datetime
import numpy as np
import matplotlib
import matplotlib.cbook as cbook
import matplotlib.dates as dates
import matplotlib.ticker as ticker
Expand Down
2 changes: 1 addition & 1 deletion examples/pylab_examples/coords_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def millions(x):
x = rand(20)
y = 1e7*rand(20)

fig, ax = plt.subplots()
fig, ax = subplots()
ax.fmt_ydata = millions
plot(x, y, 'o')

Expand Down
2 changes: 1 addition & 1 deletion examples/pylab_examples/cursor_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def mouse_move(self, event):

t = arange(0.0, 1.0, 0.01)
s = sin(2*2*pi*t)
fig, ax = plt.subplots()
fig, ax = subplots()

cursor = Cursor(ax)
#cursor = SnaptoCursor(ax, t, s)
Expand Down
11 changes: 6 additions & 5 deletions examples/pylab_examples/custom_ticker1.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
millions of dollars on the y axis
"""
from matplotlib.ticker import FuncFormatter
from pylab import *
import matplotlib.pyplot as plt
import numpy as np

x = arange(4)
x = np.arange(4)
money = [1.5e5, 2.5e6, 5.5e6, 2.0e7]

def millions(x, pos):
Expand All @@ -24,6 +25,6 @@ def millions(x, pos):

fig, ax = plt.subplots()
ax.yaxis.set_major_formatter(formatter)
bar(x, money)
xticks( x + 0.5, ('Bill', 'Fred', 'Mary', 'Sue') )
show()
plt.bar(x, money)
plt.xticks( x + 0.5, ('Bill', 'Fred', 'Mary', 'Sue') )
plt.show()
4 changes: 2 additions & 2 deletions examples/pylab_examples/dashpointlabel.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pylab
import matplotlib.pyplot as plt

DATA = ((1, 3),
(2, 4),
Expand Down Expand Up @@ -34,5 +34,5 @@
ax.set_xlim((0.0, 5.0))
ax.set_ylim((0.0, 5.0))

pylab.show()
plt.show()

4 changes: 2 additions & 2 deletions examples/pylab_examples/date_demo1.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
yahoo finance to get the data for plotting
"""

from pylab import figure, show
import matplotlib.pyplot as plt
from matplotlib.finance import quotes_historical_yahoo
from matplotlib.dates import YearLocator, MonthLocator, DateFormatter
import datetime
Expand Down Expand Up @@ -49,4 +49,4 @@ def price(x): return '$%1.2f'%x
ax.grid(True)

fig.autofmt_xdate()
show()
plt.show()
4 changes: 2 additions & 2 deletions examples/pylab_examples/date_demo2.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"""
from __future__ import print_function
import datetime
from pylab import figure, show
import matplotlib.pyplot as plt
from matplotlib.dates import MONDAY
from matplotlib.finance import quotes_historical_yahoo
from matplotlib.dates import MonthLocator, WeekdayLocator, DateFormatter
Expand Down Expand Up @@ -44,4 +44,4 @@

fig.autofmt_xdate()

show()
plt.show()
4 changes: 2 additions & 2 deletions examples/pylab_examples/date_demo_convert.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python

import datetime
from matplotlib.pyplot import figure, show
import matplotlib.pyplot as plt
from matplotlib.dates import DayLocator, HourLocator, DateFormatter, drange
from numpy import arange

Expand Down Expand Up @@ -30,4 +30,4 @@
ax.fmt_xdata = DateFormatter('%Y-%m-%d %H:%M:%S')
fig.autofmt_xdate()

show()
plt.show()
11 changes: 6 additions & 5 deletions examples/pylab_examples/date_demo_rrule.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

See https://moin.conectiva.com.br/DateUtil for help with rrules
"""
from pylab import *
import matplotlib.pyplot as plt
from matplotlib.dates import YEARLY, DateFormatter, rrulewrapper, RRuleLocator, drange
import numpy as np
import datetime

# tick every 5th easter
Expand All @@ -18,14 +19,14 @@
delta = datetime.timedelta(days=100)

dates = drange(date1, date2, delta)
s = rand(len(dates)) # make up some random y values
s = np.random.rand(len(dates)) # make up some random y values


fig, ax = plt.subplots()
plot_date(dates, s)
plt.plot_date(dates, s)
ax.xaxis.set_major_locator(loc)
ax.xaxis.set_major_formatter(formatter)
labels = ax.get_xticklabels()
setp(labels, rotation=30, fontsize=10)
plt.setp(labels, rotation=30, fontsize=10)

show()
plt.show()
4 changes: 2 additions & 2 deletions examples/pylab_examples/date_index_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from __future__ import print_function
import numpy
from matplotlib.mlab import csv2rec
from pylab import figure, show
import matplotlib.pyplot as plt
import matplotlib.cbook as cbook
from matplotlib.ticker import Formatter

Expand All @@ -37,4 +37,4 @@ def __call__(self, x, pos=0):
ax.xaxis.set_major_formatter(formatter)
ax.plot(numpy.arange(len(r)), r.close, 'o-')
fig.autofmt_xdate()
show()
plt.show()
16 changes: 4 additions & 12 deletions examples/pylab_examples/fill_between_demo.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
#!/usr/bin/env python
import matplotlib.mlab as mlab
from matplotlib.pyplot import figure, show
import matplotlib.pyplot as plt
import numpy as np

x = np.arange(0.0, 2, 0.01)
y1 = np.sin(2*np.pi*x)
y2 = 1.2*np.sin(4*np.pi*x)

fig = figure()
ax1 = fig.add_subplot(311)
ax2 = fig.add_subplot(312, sharex=ax1)
ax3 = fig.add_subplot(313, sharex=ax1)
fig, (ax1, ax2, ax3) = plt.subplots(3,1, sharex=True)

ax1.fill_between(x, 0, y1)
ax1.set_ylabel('between y1 and 0')
Expand All @@ -26,16 +22,14 @@
# this is different than calling
# fill_between(x[where], y1[where],y2[where]
# because of edge effects over multiple contiguous regions.
fig = figure()
ax = fig.add_subplot(211)
fig, (ax, ax1) = plt.subplots(2, 1, sharex=True)
ax.plot(x, y1, x, y2, color='black')
ax.fill_between(x, y1, y2, where=y2>=y1, facecolor='green', interpolate=True)
ax.fill_between(x, y1, y2, where=y2<=y1, facecolor='red', interpolate=True)
ax.set_title('fill between where')

# Test support for masked arrays.
y2 = np.ma.masked_greater(y2, 1.0)
ax1 = fig.add_subplot(212, sharex=ax)
ax1.plot(x, y1, x, y2, color='black')
ax1.fill_between(x, y1, y2, where=y2>=y1, facecolor='green', interpolate=True)
ax1.fill_between(x, y1, y2, where=y2<=y1, facecolor='red', interpolate=True)
Expand All @@ -61,6 +55,4 @@
ax.fill_between(x, 0, 1, where=y<-theta, facecolor='red', alpha=0.5, transform=trans)



show()

plt.show()
Loading