Skip to content

vba_choropleth --> ValueError: Invalid RGBA argument: #100

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

Closed
LeonardAukea opened this issue Feb 17, 2020 · 9 comments
Closed

vba_choropleth --> ValueError: Invalid RGBA argument: #100

LeonardAukea opened this issue Feb 17, 2020 · 9 comments
Assignees

Comments

@LeonardAukea
Copy link

Thank you for filing this issue! To help troubleshoot this issue, please follow
the following directions to the best of your ability before submitting an issue.
Feel free to delete this text once you've filled out the relevant requests.

Please include the output of the following in your issue submission. If you don't know how to provide the information, commands to get the relevant information from the Python interpreter will follow each bullet point.

Feel free to delete the commands after you've filled out each bullet.

  • Platform information:
posix darwin
posix.uname_result(sysname='Darwin', nodename='C02X4G43JG5J', release='19.2.0', version='Darwin Kernel Version 19.2.0: Sat Nov  9 03:47:04 PST 2019; root:xnu-6153.61.1~20/RELEASE_X86_64', machine='x86_64')
  • Python version:
3.7.5 (default, Oct 25 2019, 10:52:18) 
[Clang 4.0.1 (tags/RELEASE_401/final)]
  • SciPy version:
1.4.1
  • NumPy version:
1.18.1

I tired to use vba_choropleth but was hitting this error over and over again. After failing with my own example. I decided to try with the provided ones and all of them fail similarly.

I tried with the 3 latest reeleases splot viva pip and also conda...

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-232-bf084e6bea13> in <module>
      7 link_to_data = examples.get_path('columbus.shp')
      8 gdf = gpd.read_file(link_to_data)
----> 9 fig, _ = vba_choropleth('HOVAL', 'CRIME', gdf)
     10 plt.show()

/usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/splot/_viz_value_by_alpha_mpl.py in vba_choropleth(x_var, y_var, gdf, cmap, divergent, revert_alpha, alpha_mapclassify, rgb_mapclassify, ax, legend)
    285                                          divergent=divergent,
    286                                          revert_alpha=revert_alpha)
--> 287     gdf.plot(color=rgba, ax=ax)
    288     ax.set_axis_off()
    289     ax.set_aspect('equal')

/usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/geopandas/geodataframe.py in plot(self, *args, **kwargs)
    604         from there.
    605         """
--> 606         return plot_dataframe(self, *args, **kwargs)
    607 
    608     plot.__doc__ = plot_dataframe.__doc__

/usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/geopandas/plotting.py in plot_dataframe(df, column, cmap, color, ax, cax, categorical, legend, scheme, k, vmin, vmax, markersize, figsize, legend_kwds, classification_kwds, **style_kwds)
    500             figsize=figsize,
    501             markersize=markersize,
--> 502             **style_kwds
    503         )
    504 

/usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/geopandas/plotting.py in plot_series(s, cmap, color, ax, figsize, **style_kwds)
    339         values_ = values[poly_idx] if cmap else None
    340         plot_polygon_collection(
--> 341             ax, polys, values_, facecolor=facecolor, cmap=cmap, **style_kwds
    342         )
    343 

/usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/geopandas/plotting.py in plot_polygon_collection(ax, geoms, values, color, cmap, vmin, vmax, **kwargs)
    111                     kwargs[att] = np.take(kwargs[att], multiindex)
    112 
--> 113     collection = PatchCollection([PolygonPatch(poly) for poly in geoms], **kwargs)
    114 
    115     if values is not None:

/usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/matplotlib/collections.py in __init__(self, patches, match_original, **kwargs)
   1803             kwargs['antialiaseds'] = [p.get_antialiased() for p in patches]
   1804 
-> 1805         Collection.__init__(self, **kwargs)
   1806 
   1807         self.set_paths(patches)

/usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/matplotlib/collections.py in __init__(self, edgecolors, facecolors, linewidths, linestyles, capstyle, joinstyle, antialiaseds, offsets, transOffset, norm, cmap, pickradius, hatch, urls, offset_position, zorder, **kwargs)
    160 
    161         self._path_effects = None
--> 162         self.update(kwargs)
    163         self._paths = None
    164 

/usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/matplotlib/artist.py in update(self, props)
    972 
    973         with cbook._setattr_cm(self, eventson=False):
--> 974             ret = [_update_property(self, k, v) for k, v in props.items()]
    975 
    976         if len(ret):

/usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/matplotlib/artist.py in <listcomp>(.0)
    972 
    973         with cbook._setattr_cm(self, eventson=False):
--> 974             ret = [_update_property(self, k, v) for k, v in props.items()]
    975 
    976         if len(ret):

/usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/matplotlib/artist.py in _update_property(self, k, v)
    969                     raise AttributeError('{!r} object has no property {!r}'
    970                                          .format(type(self).__name__, k))
--> 971                 return func(v)
    972 
    973         with cbook._setattr_cm(self, eventson=False):

/usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/matplotlib/collections.py in set_facecolor(self, c)
    676         """
    677         self._original_facecolor = c
--> 678         self._set_facecolor(c)
    679 
    680     def get_facecolor(self):

/usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/matplotlib/collections.py in _set_facecolor(self, c)
    659         except AttributeError:
    660             pass
--> 661         self._facecolors = mcolors.to_rgba_array(c, self._alpha)
    662         self.stale = True
    663 

/usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/matplotlib/colors.py in to_rgba_array(c, alpha)
    292     result = np.empty((len(c), 4), float)
    293     for i, cc in enumerate(c):
--> 294         result[i] = to_rgba(cc, alpha)
    295     return result
    296 

/usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/matplotlib/colors.py in to_rgba(c, alpha)
    175         rgba = None
    176     if rgba is None:  # Suppress exception chaining of cache lookup failure.
--> 177         rgba = _to_rgba_no_colorcycle(c, alpha)
    178         try:
    179             _colors_full_map.cache[c, alpha] = rgba

/usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/matplotlib/colors.py in _to_rgba_no_colorcycle(c, alpha)
    238         # float)` and `np.array(...).astype(float)` all convert "0.5" to 0.5.
    239         # Test dimensionality to reject single floats.
--> 240         raise ValueError("Invalid RGBA argument: {!r}".format(orig_c))
    241     # Return a tuple to prevent the cached value from being modified.
    242     c = tuple(c.astype(float))

ValueError: Invalid RGBA argument: 0.11372549019607844

Any ideas what is going on here? Is the color array of the right shape?

Thank you in advance!

@LeonardAukea
Copy link
Author

Is this project still in development?

@ljwolf
Copy link
Member

ljwolf commented Mar 10, 2020

Hey, yes, thanks for the report. @slumnitz, the main maintainer of the package, has been away for some time on other business. The source issue to this is a change in Geopandas that affects how we're interacting with its geodataframe.plot() function. If I recall correctly, it's geopandas/geopandas#1178, which we need to fix here.

We'll try to address this in a bugfix release shortly.

@ljwolf
Copy link
Member

ljwolf commented Mar 10, 2020

Alternatively, what is your geopandas version?

@LeonardAukea
Copy link
Author

@ljwolf Thanks for reply I'm using version 0.6.1. It can wait for now. If I find time, I'll my try to help you out as well.

@ljwolf
Copy link
Member

ljwolf commented Mar 11, 2020

Thanks for understanding. Bivariate choropleths and value by alphas are really useful. However, this has been fixed.

Please upgrade to geopandas >= 0.6.2 for the fix.

#83

@slumnitz
Copy link
Member

@LeonardAukea are you still running into issues here with geopandas v 0.6.2?

@LeonardAukea
Copy link
Author

@slumnitz I will upgrade and try it out. I'll keep you posted

@sjsrey
Copy link
Member

sjsrey commented Apr 8, 2020

Tests are passing locally on geopandas 0.7.0. @LeonardAukea have you had a chance to test on 0.6.2?

@slumnitz
Copy link
Member

Closing due to inactivity

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

4 participants