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

Cannot pass norm argument to hist2d #430

Open
kinyatoride opened this issue Jul 10, 2023 · 0 comments
Open

Cannot pass norm argument to hist2d #430

kinyatoride opened this issue Jul 10, 2023 · 0 comments

Comments

@kinyatoride
Copy link

Description

There is an error message when I pass a norm argument to hist2d.

Steps to reproduce

import numpy as np
import proplot as pplt
import matplotlib as mpl

N = 500
state = np.random.RandomState(51423)
x = state.normal(size=(N,))
y = state.normal(size=(N,))

fig, ax = pplt.subplots()

_, _, _, m = ax.hist2d(x, y, norm=mpl.colors.LogNorm())
fig.colorbar(m)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[2], line 9
      6 fig, ax = pplt.subplots()
      8 _, _, _, m = ax.hist2d(x, y, norm=mpl.colors.LogNorm())
----> 9 fig.colorbar(m)

File ~/miniconda3/envs/basicf10/lib/python3.10/site-packages/proplot/figure.py:1634, in Figure.colorbar(self, mappable, values, loc, location, row, col, rows, cols, span, space, pad, width, **kwargs)
   1629 loc = _not_none(loc=loc, location=location, default='r')
   1630 ax = self._add_figure_panel(
   1631     loc, row=row, col=col, rows=rows, cols=cols, span=span,
   1632     width=width, space=space, pad=pad,
   1633 )
-> 1634 return ax.colorbar(mappable, values, loc='fill', **kwargs)

File ~/miniconda3/envs/basicf10/lib/python3.10/site-packages/proplot/axes/base.py:2440, in Axes.colorbar(self, mappable, values, loc, location, queue, **kwargs)
   2438     self._register_guide('colorbar', (mappable, values), loc, **kwargs)
   2439 else:
-> 2440     cb = self._draw_colorbar(mappable, values, loc=loc, **kwargs)
   2441     return cb

File ~/miniconda3/envs/basicf10/lib/python3.10/site-packages/proplot/axes/base.py:2311, in Axes._draw_colorbar(self, mappable, values, loc, space, pad, align, label, title, reverse, rotation, grid, edges, drawedges, extend, extendsize, extendfrac, tickminor, ticklen, ticklenratio, tickdir, tickdirection, tickwidth, tickwidthratio, ticklabelsize, ticklabelweight, ticklabelcolor, labelloc, labellocation, labelsize, labelweight, labelcolor, c, color, lw, linewidth, edgefix, rasterize, **kwargs)
   2309 else:
   2310     kwargs['extend'] = extend
-> 2311 obj = self.figure.colorbar(mappable, **kwargs)
...
-> 1480     raise ValueError("Invalid vmin or vmax")
   1481 value, is_scalar = self.process_value(value)
   1482 rescaled = value * (t_vmax - t_vmin)

ValueError: Invalid vmin or vmax

Equivalent steps in matplotlib

import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl

N = 500
state = np.random.RandomState(51423)
x = state.normal(size=(N,))
y = state.normal(size=(N,))

fig, ax = plt.subplots()

_, _, _, m = ax.hist2d(x, y, norm=mpl.colors.LogNorm())
fig.colorbar(m)

output

Proplot version

3.4.3
0.9.7

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

1 participant