Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError ("Contour levels must be increasing") #68

Closed
BordeauxDave opened this issue Jan 6, 2016 · 6 comments
Closed

ValueError ("Contour levels must be increasing") #68

BordeauxDave opened this issue Jan 6, 2016 · 6 comments

Comments

@BordeauxDave
Copy link

Greetings! I run your few line example exactly as it appears on your web sites, and it crashes as follows:

$ python testCorner0.py
Traceback (most recent call last):
File "testCorner0.py", line 6, in
figure = corner.corner(samples)
File "/work/myPython/epd_free-7.3-1-rh5-x86/lib/python2.7/site-packages/corner.py", line 330, in corner
*_hist2d_kwargs)
File "/work/myPython/epd_free-7.3-1-rh5-x86/lib/python2.7/site-packages/corner.py", line 519, in hist2d
ax.contour(X2, Y2, H2.T, V, *_contour_kwargs)
File "/work/myPython/epd_free-7.3-1-rh5-x86/lib/python2.7/site-packages/matplotlib-1.5.0_511.gf420992-py2.7-linux-i686.egg/matplotlib/init.py", line 1846, in inner
return func(ax, _args, *_kwargs)
File "/work/myPython/epd_free-7.3-1-rh5-x86/lib/python2.7/site-packages/matplotlib-1.5.0_511.gf420992-py2.7-linux-i686.egg/matplotlib/axes/_axes.py", line 5641, in contour
return mcontour.QuadContourSet(self, _args, *_kwargs)
File "/work/myPython/epd_free-7.3-1-rh5-x86/lib/python2.7/site-packages/matplotlib-1.5.0_511.gf420992-py2.7-linux-i686.egg/matplotlib/contour.py", line 1448, in init
ContourSet.init(self, ax, _args, *_kwargs)
File "/work/myPython/epd_free-7.3-1-rh5-x86/lib/python2.7/site-packages/matplotlib-1.5.0_511.gf420992-py2.7-linux-i686.egg/matplotlib/contour.py", line 874, in init
self._process_args(_args, *_kwargs)
File "/work/myPython/epd_free-7.3-1-rh5-x86/lib/python2.7/site-packages/matplotlib-1.5.0_511.gf420992-py2.7-linux-i686.egg/matplotlib/contour.py", line 1469, in _process_args
x, y, z = self._contour_args(args, kwargs)
File "/work/myPython/epd_free-7.3-1-rh5-x86/lib/python2.7/site-packages/matplotlib-1.5.0_511.gf420992-py2.7-linux-i686.egg/matplotlib/contour.py", line 1564, in _contour_args
self._contour_level_args(z, args)
File "/work/myPython/epd_free-7.3-1-rh5-x86/lib/python2.7/site-packages/matplotlib-1.5.0_511.gf420992-py2.7-linux-i686.egg/matplotlib/contour.py", line 1200, in _contour_level_args
raise ValueError("Contour levels must be increasing")
ValueError: Contour levels must be increasing

My OS, below. Thanks, and regards to all, David.

$ lsb_release -a
LSB Version: :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: ScientificSL
Description: Scientific Linux SL release 5.5 (Boron)
Release: 5.5
Codename: Boron

@kbarbary
Copy link
Contributor

kbarbary commented Jan 6, 2016

Assuming you're running the example block under "Usage" in the README.rst, I can't reproduce this error. I'm on Ubuntu, using conda, python 2.7.11, numpy=1.10.2, matplotlib=1.5.0.

@BordeauxDave
Copy link
Author

Le 06/01/2016 20:04, Kyle Barbary a écrit :

Assuming you're running the example block under "Usage" in the
README.rst, I can't reproduce this error. I'm on Ubuntu, using conda,
python 2.7.11, numpy=1.10.2, matplotlib=1.5.0.

Well, thank you for trying. I am indeed doing:

import numpy as np
import corner

ndim, nsamples = 5, 10000
samples = np.random.randn(ndim * nsamples).reshape([nsamples, ndim])
figure = corner.corner(samples)
figure.savefig("corner.png")

to which I add that

corner.version
u'1.0.0'

np.version
'1.10.1'
Any other suggestions are welcome, David.

@BordeauxDave
Copy link
Author

Progress! Two things...

  1. I execute to completion without errors, but with contour-less plots, by changing the line to
    corner.corner(samples, plot_contours=False)

  2. Towards the end of corner.py, the contours array V is created:
    V = np.empty(len(levels))
    for i, v0 in enumerate(levels):
    try:
    V[i] = Hflat[sm <= v0][-1]
    except:
    V[i] = Hflat[0]

A print of "levels" shows that it is ascending. But V is descending!
I added a few lines:
print (" das corner VVVVV: ", V)
V = V[::-1]
print (" das corner VVVVV: ", V)
and here is a sample of what goes to my screen:
das corner VVVVV: [ 196. 140. 71. 29.]
das corner VVVVV: [ 29. 71. 140. 196.]

With this reverse of V,
corner.corner(samples, plot_contours=True)
now works nicely.

I will leave it to you experts to understand why V is okay on some systems but not on mine!
Thank you for listening, David.

@dfm
Copy link
Owner

dfm commented Jan 7, 2016

This error was added in matplotlib 1.5.1 because of a bug in all versions of contourf prior to 1.5.0. See #65 for the relevant issue. It's not quite as simple as just sorting the levels.

@dfm
Copy link
Owner

dfm commented Jan 12, 2016

This should be fixed in version 1.0.1 (see #70). Give it a shot.

@BordeauxDave
Copy link
Author

Yes! my problem is indeed resolved. Thanks again to all, David.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants