twibiral / obsidian-execute-code

Obsidian Plugin to execute code in a note.
MIT License
994 stars 61 forks source link

Unable to embed plot #323

Closed Oveln closed 6 months ago

Oveln commented 6 months ago

when i coding it...

from sympy.plotting import plot
from sympy import *
from sympy.abc import x
import matplotlib.pyplot as plt
import time
f = 0
p = 1
for i in range(1,20):
    if (i%2==1):
        f = (x**i)/factorial(i)*p + f
        p=-p
        print(f)
        pl = plot((f,(x,-2*pi,2*pi)),(sin(x),(x,-2*pi,2*pi)),ylim=(-2,2),backend='matplotlib',show=False)
        pl[0].line_color = 'red'
        pl[1].line_color = 'blue'
        pl.show()

some window will pop up

twibiral commented 6 months ago

yes, you are creating a plot and the plot window pops up. Try to rename your plot from pl to plt and it should be embedded into the note