plt.plot() 无法使用参数ax
问题参考 TypeError: inner() got multiple values for keyword argument 'ax'
fig, ax=plt.subplots(2,1)
plt.plot(a, b, 'go-', label='line 1', linewidth=2, ax=ax) # 会报错
这时因为ax不是plt.plot()的一个有效的参数。原因是plt.plot()会调用当前活跃的axes的plot方法,和plt.gca().plot()是相同的。因此在调用时axes就被给定了。
Solution: Don't use ax as argument to plt.plot(). Instead,
- call
plt.plot(...)to plot to the current axes. Set the current axes withplt.sca(), or - directly call the
plot()method of the axes.ax.plot(...)
Mind that in the example from the question, ax is not an axes. If this is confusing, name it differently,
fig, ax_arr = plt.subplots(2,1)
ax_arr[0].plot(a, b, 'go-', label='line 1', linewidth=2)
ax_arr[0].set_xticks(a)
ax_arr[0].set_xticklabels(list(map(str,a)))
df.plot(kind='bar', ax=ax_arr[1])
plt.plot() 无法使用参数ax的更多相关文章
- matplotlib中 plt.plot() 函数中**kwargs的参数形式
plt.plot(x, y, **kwargs) **kwargs的参数大致有如下几种: color: 颜色 linestyle: 线条样式 marker: 标记风格 markerfacecolor: ...
- 4.3Python数据处理篇之Matplotlib系列(三)---plt.plot()折线图
目录 前言 (一)plt.plot()函数的本质 ==1.说明== ==2.源代码== ==3.展示效果== (二)plt.plot()函数缺省x时 ==1.说明== ==2.源代码== ==3.展示 ...
- Python的知识点 plt.plot()函数细节
1.plt.plot(x,y,format_string,**kwargs) 转自点击打开链接x轴数据,y轴数据,format_string控制曲线的格式字串 format_string 由颜色字符, ...
- plt.figure()的使用,plt.plot(),plt.subplot(),plt.subplots()和图中图
参考:https://blog.csdn.net/m0_37362454/article/details/81511427 matplotlib官方文档:https://matplotlib.org/ ...
- Python中plt.plot()、plt.scatter()和plt.legend函数的用法示例
参考:http://www.cppcns.com/jiaoben/python/471948.html https://blog.csdn.net/weixin_44825185/article/de ...
- Matlab中plot函数参数解析
功能 二维曲线绘图 语法 plot(Y) plot(X1,Y1,...) plot(X1,Y1,LineSpec,...) plot(...,'PropertyName',PropertyValue, ...
- R语言plot函数参数合集
最近用R语言画图,plot 函数是用的最多的函数,而他的参数非常繁多,由此总结一下,以供后续方便查阅. plot(x, y = NULL, type = "p", xlim = N ...
- [ZT] matlab中plot画图参数的设置
一.Matlab绘图中用到的直线属性包括: (1)LineStyle:线形 (2)LineWidth:线宽 (3)Color:颜色 (4)MarkerType:标记点的形状 (5)MarkerSize ...
- matlab中plot画图参数的设置
原文链接:http://blog.sciencenet.cn/blog-281551-573856.html 一.Matlab绘图中用到的直线属性包括: (1)LineStyle:线形 (2)Line ...
随机推荐
- MySQL中的SQL的常见优化策略
MySQL中的SQL的常见优化策略 MySQL中的索引优化 MySQL中的索引简介 1 避免全表扫描对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索 ...
- Spring的事务传播机制实例 (转)
1,Propagation.REQUIRED 如果当前没有事务,就新建一个事务,如果已经存在一个事务中,加入到这个事务中.详细解释在代码下方. 实例 员工service @Service public ...
- O023、理解Nova架构
参考https://www.cnblogs.com/CloudMan6/p/5410447.html Compute Service Nova 是OpenStack最核心的服务,负责维护和管理云环 ...
- 关于redis的几件小事(八)缓存与数据库双写时的数据一致性
1.Cache aside pattern 这是最经典的 缓存+数据库 读写模式,操作如下: ①读的时候,先读缓存,缓存没有就读数据库,然后将取出的数据放到缓存,同时返回请求响应. ②更新的时候,先删 ...
- java读取blob全身乱码
一.BLOB操作 .入库 ()JDBC方式 //通过JDBC获得数据库连接 Class.forName("oracle.jdbc.driver.OracleDriver"); Co ...
- python CGI环境搭建
本文web服务器使用的为apache. 1. 安装apache yum install -y httpd 2. 配置apache 修改apache配置文件/etc/httpd/conf/httpd.c ...
- 锋利的jQuery读书随笔
代码规范:var $variable = jQuery对象:var variable = DOM对象: jQuery对象无法使用DOM对象的任何方法,同样DOM对象也无法使用jQuery对象的任何方法 ...
- 使用pt-table-checksum检查主从一致性
使用 percona 工具检查主从不一致 可以使用 pt-table-checksum 工具检查主从数据的一致性,检查完之后默认会生成一个 percona 库以及一个 checksums 表,记录了 ...
- 在 Android 中实现 Redux 的一点经验
简评: Redux 是一个用于应用程序状态管理的开源JavaScript库,其核心是通过可管理和控制的状态来描述一个系统.这意味着其思想其实是可以应用于任何类型应用的开发的,包括移动应用. Redux ...
- 洛谷-P3389-高斯消元模板
链接: https://www.luogu.org/problem/P3389 题意: 给定一个线性方程组,对其求解 思路: 高斯消元,从第一项消到最后一项,消成一个上三角矩阵.再从最后一项依次向上回 ...