-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathmatplotlib_figure.py
executable file
·48 lines (37 loc) · 1.08 KB
/
matplotlib_figure.py
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
#!/usr/bin/env python
"""
Example that demonstrates inspecting a MatPlotLib Figure.
"""
from __future__ import print_function
import sys, logging
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
plt.ioff()
from objbrowser import browse, logging_basic_config
logger = logging.getLogger(__name__)
def make_fig(title1):
""" Creates a test Figure.
"""
x = np.linspace(10.0, 40.0, 100)
y1 = x + 1.23456789e7
fig1 = plt.figure(title1)
fig1.clear()
ax1 = fig1.add_subplot(1, 1, 1)
ax1.plot(x, y1, 'b-', picker = 5)
ax1.grid(True)
y_formatter = mpl.ticker.ScalarFormatter(useMathText=True)
y_formatter.set_useOffset(False)
ax1.yaxis.set_major_formatter(y_formatter)
return fig1
def main():
""" Main program to test stand alone
"""
logging_basic_config('DEBUG')
logger.info('Started example')
fig1 = make_fig('figure1')
exit_code = browse(fig1, name='fig1', show_dunder_attributes=False)
logging.info('Done example')
sys.exit(exit_code)
if __name__ == '__main__':
main()