-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpyplot.py
More file actions
106 lines (87 loc) · 2.59 KB
/
pyplot.py
File metadata and controls
106 lines (87 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# -*- coding: utf-8 -*-
#
# Licensed under the terms of the BSD 3-Clause
# (see plotpy/LICENSE for details)
"""
Interactive plotting widgets
============================
Overview
--------
The `pyplot` module provides an interactive plotting interface similar to
`Matplotlib`'s, i.e. with MATLAB-like syntax.
The :py:mod:`.pyplot` module was designed to be as close as possible
to the :py:mod:`matplotlib.pyplot` module, so that one could easily switch
between these two modules by simply changing the import statement. Basically,
if :mod:`plotpy` does support the plotting commands called in your script, replacing
``import matplotlib.pyplot`` by ``import plotpy.pyplot`` should be enough, as
shown in the following example:
* Simple example using `matplotlib`::
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-10, 10)
plt.plot(x, x**2, 'r+')
plt.show()
* Switching from `matplotlib` to :mod:`plotpy` is trivial::
import plotpy.pyplot as plt # only this line has changed!
import numpy as np
x = np.linspace(-10, 10)
plt.plot(x, x**2, 'r+')
plt.show()
Examples
--------
>>> import numpy as np
>>> import plotpy.pyplot as plt
>>> plt.ion() # switching to interactive mode
>>> x = np.linspace(-5, 5, 1000)
>>> plt.figure(1)
>>> plt.subplot(2, 1, 1)
>>> plt.plot(x, np.sin(x), "r+")
>>> plt.plot(x, np.cos(x), "g-")
>>> plt.errorbar(x, -1+x**2/20+.2*np.random.rand(len(x)), x/20)
>>> plt.xlabel("Axe x")
>>> plt.ylabel("Axe y")
>>> plt.subplot(2, 1, 2)
>>> img = np.fromfunction(lambda x, y: np.sin((x/200.)*(y/200.)**2), (1000, 1000))
>>> plt.xlabel("pixels")
>>> plt.ylabel("pixels")
>>> plt.zlabel("intensity")
>>> plt.gray()
>>> plt.imshow(img)
>>> plt.figure("plotyy")
>>> plt.plotyy(x, np.sin(x), x, np.cos(x))
>>> plt.ylabel("sine", "cosine")
>>> plt.show()
Reference
---------
.. autofunction:: interactive
.. autofunction:: ion
.. autofunction:: ioff
.. autofunction:: figure
.. autofunction:: gcf
.. autofunction:: gca
.. autofunction:: show
.. autofunction:: subplot
.. autofunction:: close
.. autofunction:: title
.. autofunction:: xlabel
.. autofunction:: ylabel
.. autofunction:: zlabel
.. autofunction:: yreverse
.. autofunction:: grid
.. autofunction:: legend
.. autofunction:: colormap
.. autofunction:: savefig
.. autofunction:: plot
.. autofunction:: plotyy
.. autofunction:: semilogx
.. autofunction:: semilogy
.. autofunction:: loglog
.. autofunction:: errorbar
.. autofunction:: hist
.. autofunction:: imshow
.. autofunction:: pcolor
"""
# pylint: disable=unused-import
# pylint: disable=wildcard-import
# flake8: noqa
from plotpy.plot.interactive import *