-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Open
Labels
status: needs clarificationIssues that need more information to resolve.Issues that need more information to resolve.
Description
Bug summary
This bug arises when I set wrap to True for rotated x-tick labels and draw, but resetting wrap to False cannot recover the original position of the x-tick labels.
Code for reproduction
import datetime
import numpy as np
import matplotlib.pyplot as plt
base = datetime.datetime(2005, 2, 1)
dates = [base + datetime.timedelta(hours=(2 * i)) for i in range(732)]
N = len(dates)
np.random.seed(19680801)
y = np.cumsum(np.random.randn(N))
fig, ax = plt.subplots(layout='constrained', figsize=(6, 6))
ax.plot(dates, y)
ax.set_xlim(np.datetime64('2005-02'), np.datetime64('2005-04'))
ax.tick_params(rotation=45)
xticklabels = ax.get_xticklabels()
for label in xticklabels:
label.set_wrap(False)
plt.savefig('plot1.png')
print("(plot1) first x-tick label position:", xticklabels[0].get_position())
for label in xticklabels:
label.set_wrap(True)
fig.draw_without_rendering()
for label in xticklabels:
label.set_wrap(False)
plt.savefig('plot2.png')
print("(plot2) first x-tick label position:", xticklabels[0].get_position())Actual outcome
(plot1) first x-tick label position: (np.float64(12815.0), 0)
(plot2) first x-tick label position: (np.float64(12815.0), 0)
plot1.png
plot2.png
Expected outcome
(plot1) first x-tick label position: (np.float64(12815.0), 0)
(plot2) first x-tick label position: (np.float64(12815.0), 0)
plot1.png and plot2.png are identical.
Additional information
No response
Operating system
No response
Matplotlib Version
0.2.0.dev53778+unknown.g607d2c380.g29b356467
Matplotlib Backend
No response
Python version
No response
Jupyter version
No response
Installation
None
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
status: needs clarificationIssues that need more information to resolve.Issues that need more information to resolve.