Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 261dbf4

Browse files
committed
Suppr. minor y-ticklabels w/ logit scale
1 parent d527799 commit 261dbf4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

doc/pyplots/pyplot_scales.py

Lines changed: 9 additions & 0 deletions
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)]
@@ -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)