小编Kub*_*623的帖子

绘制图例时 tikzplotlib 出现 AttributeError

我正在尝试使用 tikzplotlib 保存图形。但是,我遇到了 AttributeError:“Legend”对象没有属性“_ncol”。我目前使用 tikzplotlib 版本 0.10.1 和 matplotlib 版本 3.7.0。不使用“plt.legend()”一切正常。

下面是一个不起作用的示例:

import numpy as np
import matplotlib.pyplot as plt
import tikzplotlib

# Data
x = np.linspace(0, 10, 100)
y1 = np.sin(x)
y2 = np.cos(x)
y3 = np.tan(x)

# Plotting
plt.figure()
plt.plot(x, y1, label='sin(x)')
plt.plot(x, y2, label='cos(x)')
plt.plot(x, y3, label='tan(x)')
plt.legend()

# Save as TikZ file
tikzplotlib.save("plot.tikz")

Run Code Online (Sandbox Code Playgroud)

python latex matplotlib tikz

5
推荐指数
1
解决办法
1972
查看次数

标签 统计

latex ×1

matplotlib ×1

python ×1

tikz ×1