[Matplotlib-users] pyplot.contour() and filtered levels

Olivier B. perso.olivier.barthelemy at gmail.com
Tue Sep 24 10:17:25 EDT 2019

I did another test, with the same code but by passing to matplotlib
only the levels that are in the drawn area. My problem of line style
shift disappears.
Is it expected that when contour() filters level it will not filter
the same lines of  linewidths, linestyles, and colors? Because they
are not always the same number as the levels maybe? Or should this be
considered a bug, at least for the case when the arrays have the same
number of elements than levels? Could the documentation mention at
least a warning about it?

Le mar. 24 sept. 2019 à 14:15, Olivier B.
<perso.olivier.barthelemy at gmail.com> a écrit :
> At the switch to MPL 2.2 (from 1.5 i think), my calls to
> pyplot.clabel() started throwing ValueError. This turned out to be
> because the pyplot.contour() returned a ContourSet which had filtered
> out the levels that were not displayed in the area of the data i am
> trying to plot. As i build my list of level labels for the list of
> levels that i pass to contour(), that list could contain levels that
> had been filtered out by contour(), which throws a ValueError in
> clabel(). so i also filtered my list of levels to label based on the
> levels kept by the CountourSet.
> Now, i get the impression that there is a similar issue for the
> optional lists of line width, style, and color that we pass to
> pyplot.contour.
> If i move/zoom in a specific area of my data to draw isolines on it,
> with the same python code everytime, that uses the same list of levels
> based on the data of the whole area, and not levels based on the data
> on the drawn area, depending on the area/zoom, the lines styles seem
> to be shifted. As if levels were filtered out, but not the related
> items of the other arrays, so styles apply to a different level.
> Does someone have a hint about what's actually going on and how i
> might work around it, or, if i'm lucky, if a version more recent than
> 2.2.3 fixes this issue?

More information about the Matplotlib-users mailing list