matplotlib.units.ConversionError: Failed to convert value(s) to axis units的解决及对plt.show()的理解
matplotlib.units.ConversionError: Failed to convert value to axis units 的解决
- 背景故事
- 问题再现
- 解决 bug
- 第一次尝试
- 第二次尝试
- 函数 plt.show() 的作用
- 为什么 jupyter 中不使用 plt.show() 也不会报错
- 结尾
背景故事
- 最近两天在做日志分析,想整个
周访问量折线图
和月访问量柱状图
- 在
jupyter
中代码运行的没有问题,正确的显示了图像 - 而当我将代码复制粘贴到
py
文件中就报了错
问题再现
- 我的代码
'''
df.create_time
0 2020-12-22 11:17:29
1 2020-12-22 11:17:29
2 2020-12-22 11:17:30
3 2020-12-22 11:17:30
4 2020-12-22 11:17:31...
66370 2021-04-13 11:20:24
66371 2021-04-13 11:48:08
66372 2021-04-13 11:48:08
66373 2021-04-13 12:07:17
66374 2021-04-13 12:07:17
Name: create_time, Length: 66375, dtype: datetime64[ns]
'''
# 周访问量折线图
week_split = df.groupby(df.create_time.dt.week)['create_time'].count()
weekly = pd.date_range(df.iloc[0].create_time, periods=len(week_split), freq='w')
week_plot = plt.plot(weekly, week_split, marker='^', label='count')
plt.legend()# 月访问量柱状图
month_split = df.groupby(df.create_time.dt.month)['create_time']
months = ['%d月' % i for i in month_split.groups.keys()]
# 报错的那一句
month_bar = plt.bar(months, month_split.count().values, color='orange', width=0.3)plt.show()
- 结果运行的时候报了个错
matplotlib.units.ConversionError: Failed to convert value(s) to axis units
- 这个报错的意思是
- (我英语不好,
matplotlib.units.ConversionError: Failed to convert value(s) to axis units的解决及对plt.show()的理解相关推荐
- 成功解决matplotlib.units.ConversionError: Failed to convert value(s) to axis units: ‘LiR‘
成功解决matplotlib.units.ConversionError: Failed to convert value(s) to axis units: 'LiR' 目录 解决问题 解决思路 解 ...
- python报错ConversionError: Failed to convert value(s) to axis units
xticks(ticks=None, labels=None, **kwargs) ticks:数组类型,用于设置X轴刻度间隔 [labels]:数组类型,用于设置每个间隔的显示标签 没设置ticks ...
- 报错Failed to convert value(s) to axis units解决方法
在使用 plt.xticks的时候 遇到了这个问题 这个问题是没办法将无法将值转换为轴单位 鉴于xticks是可以接受元组和列表的,所以不存在输入值的错误, 后面发现我错误的认为 xticks的参数只 ...
- Failed to convert property value of type java.lang.String to required type java.lang.Integer for pro
Failed to convert property value of type java.lang.String to required type java.lang.Integer for pro ...
- org.springframework.web.method.annotation.MethodArgumentTypeMismatchException: Failed to convert val
org.springframework.web.method.annotation.MethodArgumentTypeMismatchException: Failed to convert val ...
- pyspark.zip/pyspark/worker.py:53: UnicodeWarning: Unicode equal comparison failed to convert both ar
/home/appleyuchi/.virtualenvs/python2.7/local/lib/python2.7/site-packages/pyspark/python/lib/pyspark ...
- Springboot文件上传报错:failed to convert java.lang.String to org.springframework.util.unit.DataSize
springboot2.1.2版本文件上传报错,我上传的是一个18M的音频,默认的配置应该是超过10M的文件就会报错,所以我将配置修改为: spring:servlet:multipart:enabl ...
- Failed to convert value of type 'java.lang.String' to required type 'java.util.Date
异常原因:Controller层获取JSP页面请求参数是String类型,而在Controller层接收时使用Date类型,属于方法参数类型不匹配异常 警告: Failed to bind reque ...
- spring:Failed to convert property value of type ‘java.lang.String‘ to required type ‘java.util.Date‘
前言 springboot有接口日期转换的经典问题,给Entity加@JsonFormat解决了输出json日期格式的输入输出问题,但是解决不了非@RequestBody/也就是普通表单提交的日期格式 ...
最新文章
- 2012年1月java_全国2012年1月自考Java语言程序设计(一)试题及答案.doc
- 为什么做了梦第二天想不起来_为什么做的梦总是想不起来?科学的解释是……...
- linux下helloworld的简单编译过程
- 三、Dockerfile的说明和编写
- tq2440实验手册qt编译问题
- Qt Creator指定动态属性
- flask和ajax通信详细步骤与完整代码
- 微信消息提醒与消息数字提示之BadgeView
- 【剑指offer】面试题33:二叉搜索树的后序遍历序列(Java)
- JAVA反射性能约慢三个量级
- 155.最小栈(力扣leetcode) 博主可答疑该问题
- log以2为底的对数
- matlab NCA,Neighborhood Component Analysis (NCA) Feature Selection
- 关于write和read以及文件读写位置
- MATLAB 中 X轴修改成特定的坐标
- 1.5Go语言的基本数据类型
- 如何找大量微信群?有没有找微信群的小程序?
- ExpandableListView实现可展开的ListView
- 每个Windows用户都应该知道的10个命令提示符技巧
- 无线路由器wifi TX/RX率和实际吞吐量的区别
热门文章
- 成功解决matplotlib.units.ConversionError: Failed to convert value(s) to axis units: ‘LiR‘