8000 Merge pull request #6779 from afvincent/fix_tutorial_pyplot_scales · matplotlib/matplotlib@a4fdd60 · GitHub
[go: up one dir, main page]

Skip to content

Commit a4fdd60

Browse files
authored
Merge pull request #6779 from afvincent/fix_tutorial_pyplot_scales
Fix tutorial pyplot scales close issue #6775
2 parents d527799 + c97fea9 commit a4fdd60

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

doc/pyplots/pyplot_scales.py

Lines 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