Skip to content

Commit

Permalink
Merge pull request matplotlib#6779 from afvincent/fix_tutorial_pyplot…
Browse files Browse the repository at this point in the history
…_scales

Fix tutorial pyplot scales

close issue matplotlib#6775
  • Loading branch information
tacaswell authored Jul 18, 2016
2 parents d527799 + c97fea9 commit a4fdd60
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion doc/pyplots/pyplot_scales.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import numpy as np
import matplotlib.pyplot as plt

from matplotlib.ticker import NullFormatter # useful for `logit` scale

# make up some data in the interval ]0, 1[
y = np.random.normal(loc=0.5, scale=0.4, size=1000)
y = y[(y > 0) & (y < 1)]
Expand Down Expand Up @@ -29,7 +31,7 @@
# symmetric log
plt.subplot(223)
plt.plot(x, y - y.mean())
plt.yscale('symlog', linthreshy=0.05)
plt.yscale('symlog', linthreshy=0.01)
plt.title('symlog')
plt.grid(True)

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

plt.show()

0 comments on commit a4fdd60

Please sign in to comment.