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

Is it possible to parser change marker size? #36

Open
LiuCMU opened this issue Apr 13, 2022 · 0 comments
Open

Is it possible to parser change marker size? #36

LiuCMU opened this issue Apr 13, 2022 · 0 comments

Comments

@LiuCMU
Copy link

LiuCMU commented Apr 13, 2022

I encountered the following error when parsing markersize:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-8-cfa7c3067ad6> in <module>
     14 fig = plt.figure(figsize=(8, 6), dpi=100)
     15 ax = fig.add_subplot(1, 1, 1, projection="scatter_density")
---> 16 density = ax.scatter_density(y_hat, y, cmap=white_viridis, markersize=10)
     17 fig.colorbar(density, label='Number of points per pixel')
     18 ax.grid()

~/miniconda3/envs/yields/lib/python3.6/site-packages/mpl_scatter_density/scatter_density_axes.py in scatter_density(self, x, y, dpi, downres_factor, color, cmap, alpha, norm, **kwargs)
     51         scatter = ScatterDensityArtist(self, x, y, dpi=dpi, downres_factor=downres_factor,
     52                                        color=color, cmap=cmap,
---> 53                                        alpha=alpha, norm=norm, **kwargs)
     54         self.add_artist(scatter)
     55 

~/miniconda3/envs/yields/lib/python3.6/site-packages/mpl_scatter_density/scatter_density_artist.py in __init__(self, ax, x, y, downres_factor, c, **kwargs)
     57         super(ScatterDensityArtist, self).__init__(ax,
     58                                                    histogram2d_func=self.histogram2d_helper,
---> 59                                                    **kwargs)
     60 
     61     def set_xy(self, x, y):

~/miniconda3/envs/yields/lib/python3.6/site-packages/mpl_scatter_density/generic_density_artist.py in __init__(self, ax, dpi, color, vmin, vmax, norm, histogram2d_func, update_while_panning, **kwargs)
     57                                                    dpi=dpi,
     58                                                    update_while_panning=update_while_panning,
---> 59                                                    **kwargs)
     60 
     61         if color is not None:

~/miniconda3/envs/yields/lib/python3.6/site-packages/mpl_scatter_density/base_image_artist.py in __init__(self, ax, dpi, array_func, update_while_panning, **kwargs)
     52     def __init__(self, ax, dpi=72, array_func=None, update_while_panning=True, **kwargs):
     53 
---> 54         super(BaseImageArtist, self).__init__(ax, **kwargs)
     55 
     56         self._array_func = array_func

~/miniconda3/envs/yields/lib/python3.6/site-packages/matplotlib/image.py in __init__(self, ax, cmap, norm, interpolation, origin, extent, filternorm, filterrad, resample, **kwargs)
    897             filterrad=filterrad,
    898             resample=resample,
--> 899             **kwargs
    900         )
    901 

~/miniconda3/envs/yields/lib/python3.6/site-packages/matplotlib/image.py in __init__(self, ax, cmap, norm, interpolation, origin, filternorm, filterrad, resample, **kwargs)
    259         self._imcache = None
    260 
--> 261         self.update(kwargs)
    262 
    263     def __getstate__(self):

~/miniconda3/envs/yields/lib/python3.6/site-packages/matplotlib/artist.py in update(self, props)
   1004 
   1005         with cbook._setattr_cm(self, eventson=False):
-> 1006             ret = [_update_property(self, k, v) for k, v in props.items()]
   1007 
   1008         if len(ret):

~/miniconda3/envs/yields/lib/python3.6/site-packages/matplotlib/artist.py in <listcomp>(.0)
   1004 
   1005         with cbook._setattr_cm(self, eventson=False):
-> 1006             ret = [_update_property(self, k, v) for k, v in props.items()]
   1007 
   1008         if len(ret):

~/miniconda3/envs/yields/lib/python3.6/site-packages/matplotlib/artist.py in _update_property(self, k, v)
   1000                 if not callable(func):
   1001                     raise AttributeError('{!r} object has no property {!r}'
-> 1002                                          .format(type(self).__name__, k))
   1003                 return func(v)
   1004 

AttributeError: 'ScatterDensityArtist' object has no property 'markersize'

The code is like this, where y and y_hat can be replaced by random lists for reproduction purpose:

from matplotlib.colors import LinearSegmentedColormap

# "Viridis-like" colormap with white background
white_viridis = LinearSegmentedColormap.from_list('white_viridis', [
    (0, '#ffffff'),
    (1e-20, '#440053'),
    (0.2, '#404388'),
    (0.4, '#2a788e'),
    (0.6, '#21a784'),
    (0.8, '#78d151'),
    (1, '#fde624'),
], N=256)

fig = plt.figure(figsize=(8, 6), dpi=100)
ax = fig.add_subplot(1, 1, 1, projection="scatter_density")
density = ax.scatter_density(y_hat, y, cmap=white_viridis, markersize=10)
fig.colorbar(density, label='Number of points per pixel')
ax.grid()
ax.set_xlim(0, 100)
ax.set_ylim(0, 100)
ax.set_xlabel("Predicted yields(Yield-BERT)")
ax.set_ylabel("Observed yields")

Thanks!

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