Python错误集锦:subplot提示ValueError: Single argument to subplot must be a three-digit integer, not 3411

原文链接:http://www.juzicode.com/archives/2498

错误提示:

使用matplotlib画子图时提示:ValueError: Single argument to subplot must be a three-digit integer, not 3411

Traceback (most recent call last):
  File "13-plt-subplot-子图限制.py", line 30, in <module>
    ax3 = plt.subplot(3411)
  File "D:\Python\Python38\lib\site-packages\matplotlib\pyplot.py", line 1142, in subplot
    ax = fig.add_subplot(*args, **kwargs)
  File "D:\Python\Python38\lib\site-packages\matplotlib\figure.py", line 1402, in add_subplot
    ax = subplot_class_factory(projection_class)(self, *args, **kwargs)
  File "D:\Python\Python38\lib\site-packages\matplotlib\axes\_subplots.py", line 39, in __init__
    self._subplotspec = SubplotSpec._from_subplot_args(fig, args)
  File "D:\Python\Python38\lib\site-packages\matplotlib\gridspec.py", line 666, in _from_subplot_args
    raise ValueError(
ValueError: Single argument to subplot must be a three-digit integer, not 3411

 

可能原因:

1、使用matplotlib的subplot()画子图时,如果是用单个参数表示行列和位置,必须是3位数xyz,z<=x*y,z只用能1~9的数值,不能大于9 。  

 

解决方法:

1、上面的第30行代码中subplot方法的入参用3个整数表示,可以改为:

    #ax3 = plt.subplot(3411)    
    ax3 = plt.subplot(3,4,11) 
  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值