你好!我试图用 matplotlib 绘制一些数据。如果我使用非常简单的命令,那么它似乎可以工作。但是当我使用下面的代码时
def plot_br():
let np = Python.import_module("numpy")
let plt = Python.import_module("matplotlib.pyplot")
let mpl = Python.import_module("matplotlib")
data = np.genfromtxt("mass_data.csv")
fig = plt.figure()
mpl.rcParams['text.latex.preamble'] = r'\usepackage{mathpazo}'
plt.rcParams['axes.linewidth'] = 2
plt.rc('text', usetex=True)
plt.rc('font', family='serif')
plt.rcParams['axes.linewidth'] = 2
fig = plt.figure(figsize=(10,8))
fig.tight_layout()
ax = fig.add_subplot(111)
ax.tick_params(which='major',direction='in',width=2,length=10,top=True,right=True, pad=7)
ax.tick_params(which='minor',direction='in',width=1,length=7,top=True,right=True)
plt.plot(data)
plt.xscale("log")
plt.yscale("log")
plt.show()
我收到以下错误
error: expression must be mutable in assignment
plt.rcParams['axes.linewidth'] = 2
~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
error: invalid call to '__call__': unexpected keyword argument: 'figsize'
fig = plt.figure(figsize=(10,8))
~~~~~~~~~~^~~~~~~~~~~~~~~~
error: invalid call to '__call__': unexpected keyword arguments: 'direction', 'length', 'pad', 'right', 'top', 'which', 'width'
ax.tick_params(which='major',direction='in',width=2,length=10,top=True,right=True, pad=7)
~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
关于为什么会发生此错误以及如何解决它有什么想法吗?这在 Mojo 中仍然不可能吗?