python中使用plot画图,图不显示
来源:互联网 发布:python 编码问题 编辑:程序博客网 时间:2024/04/28 23:42
对以下数据画图结果图不显示,修改过程如下
df3 = {'chinese':109, 'American':88, 'German': 66, 'Korea':23, 'Japan':5, 'England':118}df4 = pd.DataFrame(df3)df4.plot(kind='barh', rot=0)
运行结果:ValueError: If using all scalar values, you must pass an index
原因:缺少索引
修改后:
#方式1:df4 = pd.DataFrame.from_dict(df3,orient='index').Tdf4.plot(kind='barh', rot=0)print df4#结果: Korea England chinese German American Japan0 23 118 109 66 88 5
#方式2:df5 = pd.DataFrame({"key": df3.keys(), "value": df3.values()})print df5#结果为: key value0 Korea 231 England 1182 chinese 1093 German 664 American 885 Japan 5
# 作图语句:df4.plot()df5.plot(kind='barh', rot=0)#运行以上语句图片不显示#增加以下句子后出现图片import matplotlib.pyplot as pltplt.show()
df4的图结果
df5的图结果
阅读全文
10 0
- python中使用plot画图,图不显示
- python matplotlib 画图show()不显示图
- [转载]Matlab中使用Plot函数动态画图方法总结
- Matlab中使用Plot函数动态画图方法总结
- Matlab中使用Plot函数动态画图方法总结
- opensuse42下python matplotlib画图不显示
- python画图——matplotlib.plot 学习
- python matploblib plot画图报错
- plot画图
- python中plot实现即时数据动态显示方法
- 【PYTHON数据分析】PYCHARM中PLOT绘图不能显示出来
- Python pandas plot输出图形中显示中文乱码问题
- python中matplotlib画图中文不能显示
- matlab中plot画图参数的设置
- matlab中plot画图参数的设置
- matplotlib画图不显示
- mtlab设置plot画图函数y轴的显示范围
- matlab用plot画图后显示某个点的坐标
- 105 C语言函数指针(指向函数的指针)
- spring AOP自定义注解方式实现日志管理 详解
- Vue初体验(六)组件component
- 106 只需一招,彻底攻克C语言指针
- 驱动学习8--gpiolib的使用
- python中使用plot画图,图不显示
- android中如何在代码中直接设置View的layout_weight属性
- Educational Codeforces Round 22 C. The Tag Game(思维 搜索)
- 107 再谈main()函数,接收控制台数据
- EC插件—修改指南(汇总)
- 【ARM】一步一步移植Linux Kernel 2.6.13到板子
- SpringMVC使用 @responseBody Annotation 在老版本IE会变成下载
- WIN32SDK : TranslateAccelerator参数1填错引起加速键失效
- 108 对C语言指针的总结