|
1 |
| -#!/usr/bin/env python |
2 | 1 | # This file generates the matplotlib web page logo
|
3 | 2 |
|
4 |
| -from __future__ import print_function |
5 |
| -from pylab import * |
| 3 | +# from __future__ import print_function |
| 4 | +# Above import not necessary for Python 3 onwards. Recommend taking this out in all examples. |
| 5 | +import matplotlib.pyplot as plt |
| 6 | +import numpy as np |
6 | 7 | import matplotlib.cbook as cbook
|
7 | 8 |
|
8 | 9 | # convert data to mV
|
9 | 10 | datafile = cbook.get_sample_data('membrane.dat', asfileobj=False)
|
10 | 11 | print('loading', datafile)
|
11 | 12 |
|
12 |
| -x = 1000*0.1*fromstring(open(datafile, 'rb').read(), float32) |
| 13 | +x = 1000*0.1*np.fromstring(open(datafile, 'rb').read(), np.float32) |
13 | 14 | # 0.0005 is the sample interval
|
14 |
| -t = 0.0005*arange(len(x)) |
15 |
| -figure(1, figsize=(7, 1), dpi=100) |
16 |
| -ax = subplot(111, axisbg='y') |
17 |
| -plot(t, x) |
18 |
| -text(0.5, 0.5, 'matplotlib', color='r', |
| 15 | +t = 0.0005*np.arange(len(x)) |
| 16 | +plt.figure(1, figsize=(7, 1), dpi=100) |
| 17 | +ax = plt.subplot(111, axisbg='y') |
| 18 | +plt.plot(t, x) |
| 19 | +plt.text(0.5, 0.5, 'matplotlib', color='r', |
19 | 20 | fontsize=40, fontname=['Courier', 'Bitstream Vera Sans Mono'],
|
20 | 21 | horizontalalignment='center',
|
21 | 22 | verticalalignment='center',
|
22 | 23 | transform=ax.transAxes,
|
23 | 24 | )
|
24 |
| -axis([1, 1.72, -60, 10]) |
25 |
| -setp(gca(), 'xticklabels', []) |
26 |
| -setp(gca(), 'yticklabels', []) |
| 25 | +plt.axis([1, 1.72, -60, 10]) |
| 26 | +plt.setp(plt.gca(), 'xticklabels', []) |
| 27 | +plt.setp(plt.gca(), 'yticklabels', []) |
27 | 28 |
|
28 |
| -show() |
| 29 | +plt.show() |
0 commit comments