Python 3.x 用户警告:contour未使用以下KWARG:&x27;标签'';颜色';

Python 3.x 用户警告:contour未使用以下KWARG:&x27;标签'';颜色';,python-3.x,seaborn,valueerror,Python 3.x,Seaborn,Valueerror,我试图在我的数据集上使用Seaborn的PairGrid函数创建一个比较图。我的数据集有6列,我正试图使用PairGrid函数的.map\u上段中的scatter()函数来绘制这些列,我正在应用于整个数据帧。这里是我的dataframe对象的一个快速峰值;“年”对象被设置为数据帧的索引 以下是我的数据帧comp_pct_chg_df的数据类型: 年份对象 阿姆斯特丹64 巴塞罗那64 金斯顿64 米兰64 费城64 全球浮动64 数据类型:对象 下面是我的错误代码: # Creating a c

我试图在我的数据集上使用Seaborn的PairGrid函数创建一个比较图。我的数据集有6列,我正试图使用PairGrid函数的.map\u上段中的scatter()函数来绘制这些列,我正在应用于整个数据帧。这里是我的dataframe对象的一个快速峰值;“年”对象被设置为数据帧的索引

以下是我的数据帧comp_pct_chg_df的数据类型:

年份对象 阿姆斯特丹64 巴塞罗那64 金斯顿64 米兰64 费城64 全球浮动64 数据类型:对象

下面是我的错误代码:

# Creating a comparison plot (.PairGrid()) of all my cities' and global data's average percent change in temperature

# Set up my figure by naming it 'pct_chg_yrly_fig', then call PairGrid on the DataFrame
pct_chg_yrly_fig = sns.PairGrid(comp_pct_chg_df.dropna())

# Using map_upper we can specify what the upper triangle will look like.
pct_chg_yrly_fig.map_upper(plt.scatter,color='purple')

# We can also define the lower triangle in the figure, including the plot type (KDE) or the color map (BluePurple)
pct_chg_yrly_fig.map_lower(sns.kdeplot,cmap='cool_d')

# Finally we'll define the diagonal as a series of histogram plots of the yearly average percent change in temperature
pct_chg_yrly_fig.map_diag(plt.hist,histtype='step',linewidth=3,bins=30)

# Adding a legend
pct_chg_yrly_fig.add_legend()
有些可视化效果确实很好,比如我使用的.map_lower()函数,结果非常好。但是,我想用不同的颜色绘制每个城市,这是我在.map_upper()函数中使用的散点图。现在它是单色的,很难说哪个数据点属于哪个城市。最后,my.map\u diag()根本不打印。我不知道我做错了什么。我已经评估了我收到的ValueError消息(如下所示),并尝试操纵几十个**kwargs,特别是标签和颜色,但都没有效果。非常感谢您的帮助

Here is the ValueError msg I'm receiving: 

ValueError                                Traceback (most recent call last)
<ipython-input-38-3fcf1b69d4ef> in <module>()
     11 
     12 # Finally we'll define the diagonal as a series of histogram plots of the yearly average percent change in temperature
---> 13 pct_chg_yrly_fig.map_diag(plt.hist,histtype='step',linewidth=3,bins=30)
     14 
     15 # Adding a legend

~/anaconda3/lib/python3.6/site-packages/seaborn/axisgrid.py in map_diag(self, func, **kwargs)
   1361 
   1362                 if "histtype" in kwargs:
-> 1363                     func(vals, color=color, **kwargs)
   1364                 else:
   1365                     func(vals, color=color, histtype="barstacked", **kwargs)

~/anaconda3/lib/python3.6/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)
   3023                       histtype=histtype, align=align, orientation=orientation,
   3024                       rwidth=rwidth, log=log, color=color, label=label,
-> 3025                       stacked=stacked, normed=normed, data=data, **kwargs)
   3026     finally:
   3027         ax._hold = washold

~/anaconda3/lib/python3.6/site-packages/matplotlib/__init__.py in inner(ax, *args, **kwargs)
   1715                     warnings.warn(msg % (label_namer, func.__name__),
   1716                                   RuntimeWarning, stacklevel=2)
-> 1717             return func(ax, *args, **kwargs)
   1718         pre_doc = inner.__doc__
   1719         if pre_doc is None:

~/anaconda3/lib/python3.6/site-packages/matplotlib/axes/_axes.py in hist(***failed resolving arguments***)
   6137             color = mcolors.to_rgba_array(color)
   6138             if len(color) != nx:
-> 6139                 raise ValueError("color kwarg must have one color per dataset")
   6140 
   6141         # If bins are not specified either explicitly or via range,

ValueError: color kwarg must have one color per dataset
这是我收到的ValueError消息:
ValueError回溯(最近一次调用上次)
在()
11
12#最后,我们将对角线定义为一系列温度年平均百分比变化的柱状图
--->13%图映射图(plt.hist,histtype='step',线宽=3,箱子=30)
14
15#添加图例
map_diag中的~/anaconda3/lib/python3.6/site-packages/seaborn/axisgrid.py(self,func,**kwargs)
1361
1362如果kwargs中的“histtype”:
->1363 func(VAL,颜色=颜色,**kwargs)
1364其他:
1365 func(VAL,color=color,histtype=“barstacked”**kwargs)
历史中的~/anaconda3/lib/python3.6/site-packages/matplotlib/pyplot.py
3023 histtype=histtype,align=align,orientation=orientation,
3024 rwidth=rwidth,log=log,color=color,label=label,
->3025堆叠=堆叠,规范=规范,数据=数据,**kwargs)
3026最后:
3027 ax.\U hold=洗旧
内部的~/anaconda3/lib/python3.6/site packages/matplotlib/__init__.py(ax,*args,**kwargs)
1715警告。警告(消息%(标签名称,功能名称),
1716运行时警告,堆栈级别=2)
->1717返回函数(ax,*args,**kwargs)
1718预付款单=内部付款单__
1719如果pre_doc为无:
hist中的~/anaconda3/lib/python3.6/site-packages/matplotlib/axes//u axes.py(***解析参数失败***)
6137 color=mcolors.to_rgba_数组(彩色)
6138如果透镜(颜色)!=nx:
->6139 raise VALUERROR(“颜色kwarg必须为每个数据集提供一种颜色”)
6140
6141#如果未明确或通过范围指定箱子,
ValueError:color kwarg每个数据集必须有一种颜色
我还注意到我的索引,年份对象,在我的PairGrid的左上角绘制出来。它看起来像是一组垂直线,彼此相邻。不确定它为什么在绘图,但可能是因为值(1743-2015年)以“.0”结尾吗?当我把数据框放在一起时,我注意到了这一点(我不知道如何删除它…这里是Python newb),所以我将year列的数据类型从float64更改为string,并将其设置为我的索引。我认为这样做会使我的索引“不可行”,这意味着即使值是数字,数据类型也被设置为字符串,因此无法对它们进行计算?我是不是遗漏了什么

您将提供一个问题的详细信息,以便人们能够复制它。