Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed
Milestone
Description
Boxplot appears to reset the x-axis limits and ticks. For example, the following code
import matplotlib.pyplot as pltimport numpy as npfig = plt.figure()ax = plt.subplot()ax.set_xlim(0, 4)ax.set_xticks([0, 0.5, 1, 2, 3.5, 4])ax.set_xticklabels(['a','b','c', '2', '3.5', '4']) ax.set_ylim(0, 8)ax.set_yticks([0, 0.5, 1, 2, 3.5, 4, 8])plt.savefig('before_boxplot.png')
produces this plot
But when I execute this code next
y1 = np.random.normal(10, 3, 20)y2 = np.random.normal(3, 1, 20)ax.boxplot([y1, y2], positions = [1,2])plt.savefig('after_boxplot.png')
the plot changes to
Three things changed:
- The x-axis limits used to be 0 to 4. They are now roughly 0.5 to 2.5.
- The tick marks used to be at [0, 0.5, 1, 2, 3.5, 4]. They are now at [1, 2].
- The tick mark labels used to be ['a','b','c', '2', '3.5', '4']. They are now ['a', 'b']. Based on the changes in (1) and (2) I would have expected the tick mark labels to be ['c', '2'].
The obvious work around is to set these parameters after you have calledaxes.boxplot()
. However, reseting the axes is not consistent withaxes.plot()
,axes.bar()
,axes.imshow()
, or any other plotting method I have used. Other methods respect the user specified x limits and tick marks. This behavior also is not consistent with the y-axis behavior in boxplot. Boxplot respected the user specified y limits and tick marks.
I am working with Matplotlib 1.3.0.
Metadata
Metadata
Assignees
Labels
No labels