`brokenaxes` AttributeError: ‘SubplotSpec’对象没有属性’is_last_row’

huangapple go评论65阅读模式
英文:

brokenaxes AttributeError: 'SubplotSpec' object has no attribute 'is_last_row'

问题

I am trying to use the python brokenaxes to break both x and y axis. I run the code suggested here https://www.codespeedy.com/create-a-plot-with-broken-axis-in-python-using-matplotlib/

import matplotlib.pyplot as plt 
from brokenaxes import brokenaxes 
import numpy as np 
fig = plt.figure(figsize=(6,4)) 
baxes = brokenaxes(xlims=((-2,3),(5,8)), ylims=((0,8),(9.5,21)), hspace=.1) 
X = np.array([3,-1,0,4,5,-2,7]) 
Y = X**2
Z = X**3
baxes.plot(X,Y,label="squared") 
baxes.plot(X,Z,label="cubed") 
baxes.legend(loc="best")
plt.plot()
plt.show()

However I get error:

AttributeError: 'SubplotSpec' object has no attribute 'is_last_row'
英文:

I am trying to use the python brokenaxes to break both x and y axis. I run the code suggested here https://www.codespeedy.com/create-a-plot-with-broken-axis-in-python-using-matplotlib/

import matplotlib.pyplot as plt 
from brokenaxes import brokenaxes 
import numpy as np 
fig = plt.figure(figsize=(6,4)) 
baxes = brokenaxes(xlims=((-2,3),(5,8)), ylims=((0,8),(9.5,21)), hspace=.1) 
X = np.array([3,-1,0,4,5,-2,7]) 
Y = x**2
Z = x**3
baxes.plot(X,Y,label="squared") 
baxes.plot(X,Z,label="cubed") 
baxes.legend(loc="best")
plt.plot()
plt.show()

However I get error:

AttributeError: 'SubplotSpec' object has no attribute 'is_last_row'

答案1

得分: 0

我运行了相同的代码,我能够看到输出。但是你的代码中有一个小的拼写错误。你在Y和Z的变量中使用了小写x而不是大写X。

我还安装了matplotlib 3.7.1和brokenaxes 0.5.0。请检查这些版本。

英文:

I ran the same code, and I'm able to see the output. But there's a small typo in your code. You have put lowercase x instead of the variable uppercase X for Y and Z.

`brokenaxes` AttributeError: ‘SubplotSpec’对象没有属性’is_last_row’

Also I installed matplotlib 3.7.1 and brokenaxes 0.5.0. Please check these versions as well

huangapple
  • 本文由 发表于 2023年4月19日 17:09:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76052704.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定