python设置颜色深浅_海伯恩例外,因为颜色深浅

我想画一些应该是这样的东西:

对于一个可复制的例子,让我提供一些玩具数据:toy_data

Principal Gender loan_status

0 1 0 PAIDOFF

1 1 1 PAIDOFF

2 1 0 PAIDOFF

3 1 1 PAIDOFF

4 1 0 PAIDOFF

341 0.714286 0 COLLECTION

342 1 0 COLLECTION

343 0.714286 0 COLLECTION

344 1 0 COLLECTION

345 1 0 COLLECTION

或者选择:

^{pr2}$

我的代码如下:bins=np.linspace(toy_data.Principal.min(), toy_data.Principal.max(), 10)

g = sns.FacetGrid(toy_data, col="Gender", hue="loan_status", palette="Set1", col_wrap=2)

g.map(plt.hist, 'Principal', bins=bins, ec="k")

g.axes[-1].legend()

plt.show()

返回以下错误消息:---------------------------------------------------------------------------

ValueError Traceback (most recent call last)

in ()

1 bins=np.linspace(toy_data.Principal.min(), toy_data.Principal.max(), 10)

2 g = sns.FacetGrid(toy_data, col="Gender", hue="loan_status", palette="Set1", col_wrap=2)

----> 3 g.map(plt.hist, 'Principal', bins=bins, ec="k")

4

5 g.axes[-1].legend()

C:\ProgramData\Anaconda3\lib\site-packages\seaborn\axisgrid.py in map(self, func, *args, **kwargs)

741

742 # Draw the plot

--> 743 self._facet_plot(func, ax, plot_args, kwargs)

744

745 # Finalize the annotations and layout

C:\ProgramData\Anaconda3\lib\site-packages\seaborn\axisgrid.py in _facet_plot(self, func, ax, plot_args, plot_kwargs)

825

826 # Draw the plot

--> 827 func(*plot_args, **plot_kwargs)

828

829 # Sort out the supporting information

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\pyplot.py in hist(x, bins, range, density, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, stacked, normed, hold, data, **kwargs)

3130 histtype=histtype, align=align, orientation=orientation,

3131 rwidth=rwidth, log=log, color=color, label=label,

-> 3132 stacked=stacked, normed=normed, data=data, **kwargs)

3133 finally:

3134 ax._hold = washold

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\__init__.py in inner(ax, *args, **kwargs)

1853 "the Matplotlib list!)" % (label_namer, func.__name__),

1854 RuntimeWarning, stacklevel=2)

-> 1855 return func(ax, *args, **kwargs)

1856

1857 inner.__doc__ = _add_data_doc(inner.__doc__,

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axes\_axes.py in hist(***failed resolving arguments***)

6502 color = mcolors.to_rgba_array(color)

6503 if len(color) != nx:

-> 6504 raise ValueError("color kwarg must have one color per dataset")

6505

6506 # If bins are not specified either explicitly or via range,

ValueError: color kwarg must have one color per dataset

我不知道我为什么会收到这个错误消息,以及我应该怎么做来更正它。在

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值