pygtc
pygtc copied to clipboard
ValueError: Contour levels must be increasing
Hello there, I get the following error:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/tmp/ipykernel_3547/2353911238.py in <module>
----> 1 chainsGTC = pygtc.plotGTC(chains=chains,
2 chainLabels=["data1", "data2", "data3","data4"],
3 paramNames=Columns)
~/.local/lib/python3.9/site-packages/pygtc/pygtc.py in plotGTC(chains, **kwargs)
621 for k in range(len(truths))]
622 # Plot!
--> 623 ax = __plot2d(ax, nChains, chainsForPlot2D, weights, nBins,
624 smoothingKernel, filledPlots, colors,
625 nContourLevels, confLevels, truthsForPlot2D,
~/.local/lib/python3.9/site-packages/pygtc/pygtc.py in __plot2d(ax, nChains, chains2d, weights, nBins, smoothingKernel, filledPlots, colors, nContourLevels, confLevels, truths2d, truthColors, truthLineStyles, plotDensity, myColorMap)
1242 xbins = (xedges[1:]+xedges[:-1])/2
1243 ybins = (yedges[1:]+yedges[:-1])/2
-> 1244 ax.contourf(xbins, ybins, plotData[-1], levels=chainLevels[k],
1245 colors=colors[k][:nContourLevels][::-1])
1246
~/Programas/Anaconda3/lib/python3.9/site-packages/matplotlib/__init__.py in inner(ax, data, *args, **kwargs)
1359 def inner(ax, *args, data=None, **kwargs):
1360 if data is None:
-> 1361 return func(ax, *map(sanitize_sequence, args), **kwargs)
1362
1363 bound = new_sig.bind(ax, *args, **kwargs)
~/Programas/Anaconda3/lib/python3.9/site-packages/matplotlib/axes/_axes.py in contourf(self, *args, **kwargs)
6432 def contourf(self, *args, **kwargs):
6433 kwargs['filled'] = True
-> 6434 contours = mcontour.QuadContourSet(self, *args, **kwargs)
6435 self._request_autoscale_view()
6436 return contours
~/Programas/Anaconda3/lib/python3.9/site-packages/matplotlib/contour.py in __init__(self, ax, levels, filled, linewidths, linestyles, hatches, alpha, origin, extent, cmap, colors, norm, vmin, vmax, extend, antialiased, nchunk, locator, transform, *args, **kwargs)
775 self._transform = transform
776
--> 777 kwargs = self._process_args(*args, **kwargs)
778 self._process_levels()
779
~/Programas/Anaconda3/lib/python3.9/site-packages/matplotlib/contour.py in _process_args(self, corner_mask, *args, **kwargs)
1364 self._corner_mask = corner_mask
1365
-> 1366 x, y, z = self._contour_args(args, kwargs)
1367
1368 _mask = ma.getmask(z)
~/Programas/Anaconda3/lib/python3.9/site-packages/matplotlib/contour.py in _contour_args(self, args, kwargs)
1434 _api.warn_external('Log scale: values of z <= 0 have been masked')
1435 self.zmin = float(z.min())
-> 1436 self._process_contour_level_args(args)
1437 return (x, y, z)
1438
~/Programas/Anaconda3/lib/python3.9/site-packages/matplotlib/contour.py in _process_contour_level_args(self, args)
1117
1118 if len(self.levels) > 1 and np.min(np.diff(self.levels)) <= 0.0:
-> 1119 raise ValueError("Contour levels must be increasing")
1120
1121 def _process_levels(self):
ValueError: Contour levels must be increasing
using: matplotlib: 3.4.3
Is it a problem with matplotlib? or am I doing it wrong?
I am using:
chainsGTC = pygtc.plotGTC(chains=chains,
chainLabels=["data1", "data2", "data3","data4"],
paramNames=Columns)
The chains is a list with np arrays with shapes:
chains[0].shape
(51, 4)
chains[1].shape
(130, 4)
chains[2].shape
(238, 4)
chains[3].shape
(163, 4)
Hi! I typically get this error when the chains are not converged. Your chains look very short, can you confirm that they are long / converged enough?
Thanks that's right, they are very shot, thankyou!!
El jue, 19 may 2022 a la(s) 02:45, Sebastian Bocquet ( @.***) escribió:
Hi! I typically get this error when the chains are not converged. Your chains look very short, can you confirm that they are long / converged enough?
— Reply to this email directly, view it on GitHub https://github.com/SebastianBocquet/pygtc/issues/32#issuecomment-1131353397, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQ63PGGFDEHPD2JK4JB3PFDVKXWQ3ANCNFSM5WK6EI6A . You are receiving this because you authored the thread.Message ID: @.***>