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 e2b1184

Browse filesBrowse files
committed
Merge pull request #6779 from afvincent/fix_tutorial_pyplot_scales
Fix tutorial pyplot scales close issue #6775
1 parent 4a14291 commit e2b1184
Copy full SHA for e2b1184

File tree

Expand file treeCollapse file tree

1 file changed

+10
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-1
lines changed

‎doc/pyplots/pyplot_scales.py

Copy file name to clipboardExpand all lines: doc/pyplots/pyplot_scales.py
+10-1Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import numpy as np
22
import matplotlib.pyplot as plt
33

4+
from matplotlib.ticker import NullFormatter # useful for `logit` scale
5+
46
# make up some data in the interval ]0, 1[
57
y = np.random.normal(loc=0.5, scale=0.4, size=1000)
68
y = y[(y > 0) & (y < 1)]
@@ -29,7 +31,7 @@
2931
# symmetric log
3032
plt.subplot(223)
3133
plt.plot(x, y - y.mean())
32-
plt.yscale('symlog', linthreshy=0.05)
34+
plt.yscale('symlog', linthreshy=0.01)
3335
plt.title('symlog')
3436
plt.grid(True)
3537

@@ -39,5 +41,12 @@
3941
plt.yscale('logit')
4042
plt.title('logit')
4143
plt.grid(True)
44+
# Format the minor tick labels of the y-axis into empty string with
45+
# the `NullFormatter`, to avoid cumbering it with too many labels.
46+
plt.gca().yaxis.set_minor_formatter(NullFormatter())
47+
# Adjust the subplot layout, because the logit one may take more space than
48+
# usual, due to y-tick labels like "1 - 10^3"
49+
plt.subplots_adjust(top=0.92, bottom=0.08, left=0.10, right=0.95, hspace=0.25,
50+
wspace=0.35)
4251

4352
plt.show()

0 commit comments

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