"Line2D"对象没有属性“种类" [英] 'Line2D' object has no property 'kind'

查看:158
本文介绍了"Line2D"对象没有属性“种类"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始学习熊猫,当时我想绘制2013年车站平均值的条形图,以创建 fig,ax = plt.subplots()对象并添加绘制到所创建的斧头',我在运行代码"Line2D"对象的这一部分时遇到此错误,没有属性种类"

I just started learning pandas, when I wanted to make a bar plot of the mean of the stations in year of 2013 on creating a fig, ax = plt.subplots() object and adding the plot to the created ax' I am getting this error while running this part of the code 'Line2D' object has no property 'kind'


fig,ax = plt.subplots(1)
x= data.columns
y=data['2013'].mean()
ax.plot(x,y,kind='bar')
```````````````````````

[this is my DATASET]

                      L06_347   LS06_347    LS06_348
Time            
2009-01-01 00:00:00 0.137417    0.097500    0.016833
2009-01-01 03:00:00 0.131250    0.088833    0.016417
2009-01-01 06:00:00 0.113500    0.091250    0.016750
2009-01-01 09:00:00 0.135750    0.091500    0.016250
... ... ... ...
2013-01-01 15:00:00 1.420000    1.420000    0.096333
2013-01-01 18:00:00 1.178583    1.178583    0.083083
2013-01-01 21:00:00 0.898250    0.898250    0.077167
2013-01-02 00:00:00 0.860000    0.860000    0.075000
11697 rows × 3 columns

另一方面,我尝试使用此代码选择不同年份的4月,5月和6月的所有数据

on the other hand I try to select all data in April, May and June for all different years with this code

data[(data.index.month == 4) & (data.index.month == 5) & (data.index.month == 6)]

我也尝试过这种方式

data.loc[(data.index.month == 4) & (data.index.month == 5) & (data.index.month == 6)]

它什么也没显示,只是空列显示.

it shows me nothing, just a display of empty columns.

推荐答案

对于第一个问题,您必须使用 data.plot(x,y,kind ='bar'),而不是 ax.plot().

For your first question, you have to use data.plot(x, y, kind='bar'), not ax.plot().

fig,ax = plt.subplots(1)
ax = data['2013'].mean().plot(kind='bar')
ax.set_xlabel('x label name')   # replace with the labels you want
ax.set_ylabel('Mean')
plt.xticks(rotation=30)
plt.show()

第二个问题-使用 data [data.index.month.isin([4,5,6])]

这篇关于"Line2D"对象没有属性“种类"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆