Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5ef5995

Browse filesBrowse files
authored
Merge pull request #7137 from afvincent/doc_engformatter_example
DOC: improve engineering formatter example
2 parents d1b837f + 54a67a6 commit 5ef5995
Copy full SHA for 5ef5995

File tree

Expand file treeCollapse file tree

1 file changed

+4
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-2
lines changed

‎examples/api/engineering_formatter.py

Copy file name to clipboardExpand all lines: examples/api/engineering_formatter.py
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77

88
from matplotlib.ticker import EngFormatter
99

10+
prng = np.random.RandomState(123)
11+
1012
fig, ax = plt.subplots()
1113
ax.set_xscale('log')
12-
formatter = EngFormatter(unit='Hz', places=1)
14+
formatter = EngFormatter(unit='Hz')
1315
ax.xaxis.set_major_formatter(formatter)
1416

1517
xs = np.logspace(1, 9, 100)
16-
ys = (0.8 + 0.4*np.random.uniform(size=100))*np.log10(xs)**2
18+
ys = (0.8 + 0.4 * prng.uniform(size=100)) * np.log10(xs)**2
1719
ax.plot(xs, ys)
1820

1921
plt.show()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.