This is a bug report.
I am using matplotlib 0.99.1 on Windows. When using contour with the keyword
argument locator=ticker.FixedLocator(levels), the plot is always dropping the first
and last contour level. If there are less than 3 levels, contour.py throws an
exception.
My workaround is to duplicate the first and last levels when using the fixed locator:
e.g. my argument becomes
locator=FixedLocator( [levels[0]] + levels + [levels[-1]] )
I have traced the problem to the last line in contour.py, method _autolev() which
strips the first and last levels if the contours are not filled:
return lev[1:-1]
This line occurs at line 682 in my version of contour.py which came with the 0.991 installation.
I realize that I could specify the levels in the argument V and this does work. However
this code is embedded in GUI-ness which allows the user to choose how the contours
are selected. Passing the locator seems to be the best option code-wise.
Thank you,
Dave Smith
···
David Smith wrote:
This is a bug report.
I am using matplotlib 0.99.1 on Windows. When using contour with the keyword
argument locator=ticker.FixedLocator(levels), the plot is always dropping the first
and last contour level. If there are less than 3 levels, contour.py throws an
exception.
My workaround is to duplicate the first and last levels when using the fixed locator: e.g. my argument becomes
locator=FixedLocator( [levels[0]] + levels + [levels[-1]] )
I have traced the problem to the last line in contour.py, method _autolev() which
strips the first and last levels if the contours are not filled:
return lev[1:-1]
This line occurs at line 682 in my version of contour.py which came with the 0.991 installation.
I realize that I could specify the levels in the argument V and this does work. However
this code is embedded in GUI-ness which allows the user to choose how the contours
are selected. Passing the locator seems to be the best option code-wise.
I committed a small change to svn trunk (r8190) that I think will handle your use case without fouling anything else up.
Eric
···
Thank you,
Dave Smith
Eric,
Thank you, thank you, thank you. This not only fixes the problem I reported with with
FixedLocator(…) but also another one where I was using MultipleLocator(…) and getting
the same problem issue with dropping first and last contours. The later isn’t as easy
to work-around but your change fixed it.
David Smith
···
On Sat, Mar 13, 2010 at 12:30 PM, Eric Firing <efiring@…202…> wrote:
David Smith wrote:
This is a bug report.
I am using matplotlib 0.99.1 on Windows. When using contour with the keyword
argument locator=ticker.FixedLocator(levels), the plot is always dropping the first
and last contour level. If there are less than 3 levels, contour.py throws an
exception.
My workaround is to duplicate the first and last levels when using the fixed locator: e.g. my argument becomes
locator=FixedLocator( [levels[0]] + levels + [levels[-1]] )
I have traced the problem to the last line in contour.py, method _autolev() which
strips the first and last levels if the contours are not filled:
return lev[1:-1]
This line occurs at line 682 in my version of contour.py which came with the 0.991 installation.
I realize that I could specify the levels in the argument V and this does work. However
this code is embedded in GUI-ness which allows the user to choose how the contours
are selected. Passing the locator seems to be the best option code-wise.
I committed a small change to svn trunk (r8190) that I think will handle your use case without fouling anything else up.
Eric
Thank you,
Dave Smith