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 ...
随机推荐
- python网络爬虫(3)python爬虫遇到的各种问题(python版本、进程等)
import urllib2 源地址 在python3.3里面,用urllib.request代替urllib2 import urllib.request as urllib2 import coo ...
- spring + dubbo 学习
新启动的项目中可能会使用到dubbo,因为之前并没有接触过,所以先小试一下 示例运行环境准备:OS X 10.10.5 + java version "1.8.0_40" zook ...
- Java常见数据结构
HashMap深入浅出 HashMap数据结构 HashMap的本质就是一个数组加链表,数组默认长度是16,存储的元素达到总长度的75%就会扩容一倍.map.put(key,val),实际上就是根据h ...
- Mysql学习(一)之简单介绍
数据库简介 数据库分类 关系型数据库:MySQL.Oracle.SQLServer.Access.db2.fox pro 文件型数据库:sqlite.mongodb 空间型数据库: 数据库分为两端 数 ...
- json串到java对象
json串到java对象 前端传入参数json字符串,格式如下: {"语文":"88","数学":"78"," ...
- 使用TensorFlow玩GTA5
小白学TensorFlow(一) tensorflow安装 在安装之前,您必须选择以下类型的TensorFlow之一来安装: TensorFlow仅支持CPU支持.如果您的系统没有NVIDIA®G ...
- 一,python简介 笔记
python历史 1,1989年圣诞节,Guido von Rossum开始编写python语言编译器 2,1991年2月,第一个python编译器诞生,是c语言实现的,后面又出现了c#和java版本 ...
- 批处理清除svn版本信息
for /r . %%a in (.) do @if exist "%%a\.svn" rd /s /q "%%a\.svn"
- windows时钟服务设置
运行Regedit,打开注册表编辑器. 找到注册表项HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config\,将Anno ...
- 第五章Java
2 [单选题] 已知MyInterface是一个接口,ClassA是实现该接口的一个类,ClassB是ClassA的子类,则下面说法哪个正确? A. ClassB obj = new ClassA ...