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

Olivier B. perso.olivier.barthelemy at gmail.com
Tue Sep 24 08:15:27 EDT 2019


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