dcss_supplementary
dcss_supplementary copied to clipboard
Chapter 7: Conditional histograms Figure 7.12 TypeError: 'ListedColormap' object is not iterable
Hi!
I'm using a MacBook Air Apple M2, macOS Sonoma, Version 14.1.1. I was not able to use the enviroment that came with the examples, but I installed each package individually. I attach the list of packages installed in the env.
Packages installed in the env.txt
TypeError Traceback (most recent call last) Cell In[20], line 3 1 grayscale_cmap = sns.cubehelix_palette(50, hue=0.05, rot=0, light=0.9, dark=0, as_cmap=True) ----> 3 ax = sns.displot(fsdf, x="v2x_egaldem", hue="e_boix_regime", palette=grayscale_cmap) 4 ax.set(xlabel='Egalitarian Democracy Index') 5 plt.show()
File ~/anaconda3/envs/dcss/lib/python3.9/site-packages/seaborn/distributions.py:2113, in displot(data, x, y, hue, row, col, weights, kind, rug, rug_kws, log_scale, legend, palette, hue_order, hue_norm, color, col_wrap, row_order, col_order, height, aspect, facet_kws, **kwargs) 2094 def displot( 2095 data=None, *, 2096 # Vector variables (...) 2105 **kwargs, 2106 ): 2108 p = _DistributionPlotter( 2109 data=data, 2110 variables=dict(x=x, y=y, hue=hue, weights=weights, row=row, col=col), 2111 ) -> 2113 p.map_hue(palette=palette, order=hue_order, norm=hue_norm) 2115 _check_argument("kind", ["hist", "kde", "ecdf"], kind) 2117 # --- Initialize the FacetGrid object 2118 2119 # Check for attempt to plot onto specific axes and warn
File ~/anaconda3/envs/dcss/lib/python3.9/site-packages/seaborn/_base.py:838, in VectorPlotter.map_hue(self, palette, order, norm, saturation) 837 def map_hue(self, palette=None, order=None, norm=None, saturation=1): --> 838 mapping = HueMapping(self, palette, order, norm, saturation) 839 self._hue_map = mapping
File ~/anaconda3/envs/dcss/lib/python3.9/site-packages/seaborn/_base.py:150, in HueMapping.init(self, plotter, palette, order, norm, saturation) 147 elif map_type == "categorical": 149 cmap = norm = None --> 150 levels, lookup_table = self.categorical_mapping( 151 data, palette, order, 152 ) 154 # --- Option 3: datetime mapping 155 156 else: 157 # TODO this needs actual implementation 158 cmap = norm = None
File ~/anaconda3/envs/dcss/lib/python3.9/site-packages/seaborn/_base.py:248, in HueMapping.categorical_mapping(self, data, palette, order) 246 colors = self._check_list_length(levels, palette, "palette") 247 else: --> 248 colors = color_palette(palette, n_colors) 250 lookup_table = dict(zip(levels, colors)) 252 return levels, lookup_table
File ~/anaconda3/envs/dcss/lib/python3.9/site-packages/seaborn/palettes.py:245, in color_palette(palette, n_colors, desat, as_cmap) 240 palette = [desaturate(c, desat) for c in palette] 242 if not as_cmap: 243 244 # Always return as many colors as we asked for --> 245 pal_cycle = cycle(palette) 246 palette = [next(pal_cycle) for _ in range(n_colors)] 248 # Always return in r, g, b tuple format
TypeError: 'ListedColormap' object is not iterable