|
1 | | -#!/usr/bin/env python |
2 | | -from pylab import * |
3 | | -#from matplotlib.pyplot import * |
4 | | -#from numpy import arange |
5 | | - |
6 | | -if 1: |
7 | | - figure(figsize=(7, 4)) |
8 | | - ax = subplot(121) |
9 | | - ax.set_aspect(1) |
10 | | - plot(arange(10)) |
11 | | - xlabel('this is a xlabel\n(with newlines!)') |
12 | | - ylabel('this is vertical\ntest', multialignment='center') |
13 | | - #ylabel('this is another!') |
14 | | - text(2, 7, 'this is\nyet another test', |
| 1 | +import matplotlib.pyplot as plt |
| 2 | +import numpy as np |
| 3 | + |
| 4 | +plt.figure(figsize=(7, 4)) |
| 5 | +ax = plt.subplot(121) |
| 6 | +ax.set_aspect(1) |
| 7 | +plt.plot(np.arange(10)) |
| 8 | +plt.xlabel('this is a xlabel\n(with newlines!)') |
| 9 | +plt.ylabel('this is vertical\ntest', multialignment='center') |
| 10 | +plt.text(2, 7, 'this is\nyet another test', |
15 | 11 | rotation=45, |
16 | 12 | horizontalalignment='center', |
17 | 13 | verticalalignment='top', |
18 | 14 | multialignment='center') |
19 | 15 |
|
20 | | - grid(True) |
| 16 | +plt.grid(True) |
21 | 17 |
|
22 | | - subplot(122) |
| 18 | +plt.subplot(122) |
23 | 19 |
|
24 | | - text(0.29, 0.7, "Mat\nTTp\n123", size=18, |
| 20 | +plt.text(0.29, 0.7, "Mat\nTTp\n123", size=18, |
25 | 21 | va="baseline", ha="right", multialignment="left", |
26 | 22 | bbox=dict(fc="none")) |
27 | 23 |
|
28 | | - text(0.34, 0.7, "Mag\nTTT\n123", size=18, |
| 24 | +plt.text(0.34, 0.7, "Mag\nTTT\n123", size=18, |
29 | 25 | va="baseline", ha="left", multialignment="left", |
30 | 26 | bbox=dict(fc="none")) |
31 | 27 |
|
32 | | - text(0.95, 0.7, "Mag\nTTT$^{A^A}$\n123", size=18, |
| 28 | +plt.text(0.95, 0.7, "Mag\nTTT$^{A^A}$\n123", size=18, |
33 | 29 | va="baseline", ha="right", multialignment="left", |
34 | 30 | bbox=dict(fc="none")) |
35 | 31 |
|
36 | | - xticks([0.2, 0.4, 0.6, 0.8, 1.], |
| 32 | +plt.xticks([0.2, 0.4, 0.6, 0.8, 1.], |
37 | 33 | ["Jan\n2009", "Feb\n2009", "Mar\n2009", "Apr\n2009", "May\n2009"]) |
38 | 34 |
|
39 | | - axhline(0.7) |
40 | | - title("test line spacing for multiline text") |
| 35 | +plt.axhline(0.7) |
| 36 | +plt.title("test line spacing for multiline text") |
41 | 37 |
|
42 | | -subplots_adjust(bottom=0.25, top=0.8) |
43 | | -draw() |
44 | | -show() |
| 38 | +plt.subplots_adjust(bottom=0.25, top=0.8) |
| 39 | +plt.draw() |
| 40 | +plt.show() |
0 commit comments