-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Open
Labels
Description
Bug summary
Contour labelling is hard, but our algorithm seems to create lots of overlaps when there is substantial room for non-overlaps.
Code for reproduction
import matplotlib.pyplot as plt
import numpy as np
import matplotlib as mpl
fig, ax = plt.subplots(1, 1, figsize=(2, 4))
x = np.linspace(1, 4, 20)
y = np.linspace(1, 4, 20)
X, Y = np.meshgrid(x, y)
cnt = ax.contour(X, Y, X, levels=20)
ax.clabel(cnt, levels=cnt.levels)
plt.show()
Actual outcome
Expected outcome
The labels would be staggered vertically.
Additional information
I'm not aware if this ever worked optimally. There was some optimization of the algorithm in #19018, but checking out v3.3.4 doesn't change the result.
Operating system
No response
Matplotlib Version
master...
Matplotlib Backend
No response
Python version
No response
Jupyter version
No response
Installation
No response
janosh and wgst