Ask Your Question
1

Combine sage plot with matplotlib

asked 2024-02-27 14:07:46 +0200

Rowing0914 gravatar image

updated 2024-02-28 20:38:04 +0200

FrédéricC gravatar image

I would like to combine the plots (canvases) of Sage and Matplotlib in one plot. The following is an example script. As you can see (if you run), that Sage is just putting another image on top of the canvas of Matplotlib... Any way to just update the canvas of matplotlib to combine two plots in one plot?

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)
plt.show()
edit retag flag offensive close merge delete

Comments

Rowing0914 gravatar imageRowing0914 ( 2024-02-27 14:08:35 +0200 )edit
Rowing0914 gravatar imageRowing0914 ( 2024-02-28 12:09:04 +0200 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2024-02-28 11:49:56 +0200

eric_g gravatar image

What about something like

c_matplotlib = c.matplotlib(figure=fig, sub=ax)
edit flag offensive delete link more

Comments

It worked!! Thank you so much!

Rowing0914 gravatar imageRowing0914 ( 2024-02-28 12:08:52 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2024-02-27 14:07:46 +0200

Seen: 221 times

Last updated: Feb 28