问题参考 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,

  1. call plt.plot(...) to plot to the current axes. Set the current axes with plt.sca(), or
  2. 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的更多相关文章

  1. matplotlib中 plt.plot() 函数中**kwargs的参数形式

    plt.plot(x, y, **kwargs) **kwargs的参数大致有如下几种: color: 颜色 linestyle: 线条样式 marker: 标记风格 markerfacecolor: ...

  2. 4.3Python数据处理篇之Matplotlib系列(三)---plt.plot()折线图

    目录 前言 (一)plt.plot()函数的本质 ==1.说明== ==2.源代码== ==3.展示效果== (二)plt.plot()函数缺省x时 ==1.说明== ==2.源代码== ==3.展示 ...

  3. Python的知识点 plt.plot()函数细节

    1.plt.plot(x,y,format_string,**kwargs) 转自点击打开链接x轴数据,y轴数据,format_string控制曲线的格式字串 format_string 由颜色字符, ...

  4. plt.figure()的使用,plt.plot(),plt.subplot(),plt.subplots()和图中图

    参考:https://blog.csdn.net/m0_37362454/article/details/81511427 matplotlib官方文档:https://matplotlib.org/ ...

  5. Python中plt.plot()、plt.scatter()和plt.legend函数的用法示例

    参考:http://www.cppcns.com/jiaoben/python/471948.html https://blog.csdn.net/weixin_44825185/article/de ...

  6. Matlab中plot函数参数解析

    功能 二维曲线绘图 语法 plot(Y) plot(X1,Y1,...) plot(X1,Y1,LineSpec,...) plot(...,'PropertyName',PropertyValue, ...

  7. R语言plot函数参数合集

    最近用R语言画图,plot 函数是用的最多的函数,而他的参数非常繁多,由此总结一下,以供后续方便查阅. plot(x, y = NULL, type = "p", xlim = N ...

  8. [ZT] matlab中plot画图参数的设置

    一.Matlab绘图中用到的直线属性包括: (1)LineStyle:线形 (2)LineWidth:线宽 (3)Color:颜色 (4)MarkerType:标记点的形状 (5)MarkerSize ...

  9. matlab中plot画图参数的设置

    原文链接:http://blog.sciencenet.cn/blog-281551-573856.html 一.Matlab绘图中用到的直线属性包括: (1)LineStyle:线形 (2)Line ...

随机推荐

  1. hbase启动后HMaster几秒后死掉

    通过 http://s128:16010 无法访问Hbase Web端 查看master日志,有报错: 2019-08-30 16:27:35,137 ERROR [master/s128:16000 ...

  2. Tomcat error: failed to start connector [connector[HTTP/1.1-8080]]

    出现这个问题多半是因为8080端口被占用了.换一个端口试试

  3. avascript中实现垃圾桶的功能

    javascript中实现垃圾桶的功能,就像折垃圾桶在拖动目标上触发事件 (源元素):ondragstart - 用户开始拖动元素时触发ondrag - 元素正在拖动时触发ondragend - 用户 ...

  4. 设置VMware 以及指定 虚拟机 ,开机自启动

    进入开机自启动目录 C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp 重命名为 start.bat 编辑 这个文件,编辑之后Ct ...

  5. TypeScript如何添加自定义d.ts文件(转)

    方法一:https://dingyuliang.me/angular-6-typescript-2-9-typings-d-ts-cant-find-names/ 方法二:https://www.be ...

  6. docker快速入门02——在docker下开启mysql5.6 binlog日志

    1.检查容器状态 [root@localhost ~]# docker ps 执行这个命令可以看到所有正在运行当中的容器,如果加上-a参数,就可以看到所有的容器包括停止的. 我们可以看到容器正在运行当 ...

  7. Delphi RadioGroup 组件

  8. 标准C语言(3)

    操作符用来描述对数字的处理规则根据操作符所需要配合的数字个数把操作符分为单目操作符,双目操作符和三目操作符 C语言里用+,-,*和/表示加减乘除四则运算,它们都是双目操作符,如果参与除法计算的两个数字 ...

  9. 读《JavaScript面向对象编程指南》(二)

    第五章 原型 在JavaScript中,所有函数都会拥有一个 prototype 的属性,默认初始值为空对象. 可以在相关的原型对象中添加新的方法和属性,甚至可以用自定义对象来完全替换掉原有的原型对象 ...

  10. Linux tcpdump命令详解与Wireshark

    简介 用简单的话来定义tcpdump,就是:dump the traffic on a network,根据使用者的定义对网络上的数据包进行截获的包分析工具. tcpdump可以将网络中传送的数据包的 ...