-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed
Labels
status: inactiveMarked by the “Stale” Github ActionMarked by the “Stale” Github Action
Milestone
Description
Bug report
Bug summary
Not sure it's a bug, but in the following example the order in which you change subplots properties matters.
Suppose you have several subplots with the shared axis and you set ticks for this axis with the range outside the data. Doing it for all subplots one by one, you get ticks placed correctly on the last subplot and incorrectly on all others.
Code for reproduction
import matplotlib.pyplot as plt
fig, ax = plt.subplots(3, 1, sharex=True)
ax[0].scatter([0, 1], [0, 1])
ax[0].set_xticks([0, 1, 2])
ax[1].scatter([0, 1], [0, 1])
ax[1].set_xticks([0, 1, 2])
ax[2].scatter([0, 1], [0, 1])
ax[2].set_xticks([0, 1, 2])
plt.show()
Expected outcome
Let's try the same code, but change all subplots properties afterwards.
import matplotlib.pyplot as plt
fig, ax = plt.subplots(3, 1, sharex=True)
ax[0].scatter([0, 1], [0, 1])
ax[1].scatter([0, 1], [0, 1])
ax[2].scatter([0, 1], [0, 1])
plt.setp(ax, xticks=[0, 1, 2])
"""
Alternatively,
ax[0].set_xticks([0, 1, 2])
ax[1].set_xticks([0, 1, 2])
ax[2].set_xticks([0, 1, 2])
"""
plt.show()
Not so expected outcome
Finally, change all subplots properties somewhere earlier.
import matplotlib.pyplot as plt
fig, ax = plt.subplots(3, 1, sharex=True)
ax[0].scatter([0, 1], [0, 1])
plt.setp(ax, xticks=[0, 1, 2])
ax[1].scatter([0, 1], [0, 1])
ax[2].scatter([0, 1], [0, 1])
plt.show()
Matplotlib version
Matplotlib 2.0.0 (installed using Anaconda)
Python 3.5.3
Fedora 25
csbrown
Metadata
Metadata
Assignees
Labels
status: inactiveMarked by the “Stale” Github ActionMarked by the “Stale” Github Action