-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Description
I am writing to express my concern regarding the handling of legends for contour plots in recent versions of matplotlib. While line plots (plot) allow direct assignment of legend labels via the label argument, contour plots (contour) do not support this feature. Attempts to use the label argument with contour result in warnings, and the recommended workaround is to use dummy Line2D objects for legend handles. This approach is unintuitive and does not reflect the actual plotted lines.
Furthermore, the previously available method of assigning labels via the collections attribute (e.g., img.collections[0].set_label("label")) has been deprecated, making it difficult to associate legend entries with the actual contour lines.
I strongly request that future versions of matplotlib provide a straightforward and stable way to assign legend labels directly to contour plots, similar to how it is done for line plots. This would greatly improve usability and code clarity for users who wish to create accurate and meaningful legends for their visualizations.