合并 SageMath 和 Matplotlib 的绘图

问题描述 投票:0回答:1

如何将 Sage 和 Matplotlib 的图合并为一个图,而不使一个图重叠另一个图?

这是一个示例脚本,我尝试将 Sage 和 Matplotlib 绘图结合起来:

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
x = [1, 2, 3, 4, 5]
y = [1, 2, 3, 4, 5]
ax.plot(x, y)

c = circle((1,1),1)
c_matplotlib = c.matplotlib(figure=fig)  # this Returns matplotlib.figure.Figure object

plt.show()

但是,当我运行这个脚本时,Sage 只是将另一个图像放在 Matplotlib 画布上。有没有办法更新 Matplotlib 的画布以将两个图合并为一个?

图片

参考

matplotlib sage
1个回答
0
投票

JohanC 的工作解决方案

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
x = [1, 2, 3, 4, 5]
y = [1, 2, 3, 4, 5]
ax.plot(x, y)
c = circle((1,1),1)
c_matplotlib = c.matplotlib(figure=fig, sub=ax)
plt.show()

© www.soinside.com 2019 - 2024. All rights reserved.