plots not appearing

asked 2025-10-13 11:31:31 +0200

Chris-D gravatar image

i installed sage with conda: conda create -n sage sage python=3.12

everything works perfectly but plots won't show in jupyter notebooks:

c=circle((0,0), 1, rgbcolor=(1,1,0))
 c.show()

i can save plots with command:

c.save('filename.png')

in a python script i tried:

from sage.all import *

# Define a variable and a function
x = var('x')
f = sin(x) * exp(-0.1 * x)

# Create the plot (Sage wraps matplotlib under the hood)
p = plot(f, (x, -10, 10), color='blue', legend_label='sin(x)*e^(-0.1x)', figsize=6)

# Show the plot
p.show()

This does not work either:

from sage.all import *
import matplotlib.pyplot as plt

x = var('x')
f = sin(x) * exp(-0.1 * x)

p = plot(f, (x, -10, 10), color='blue', legend_label='sin(x)*e^(-0.1x)', figsize=6)

# Convert Sage plot to matplotlib figure and show
fig = p.matplotlib()
plt.show()

Code compiles with no error.

edit retag flag offensive close merge delete

Comments

Welcome to Ask Sage! Thank you for your question.

slelievre gravatar imageslelievre ( 2025-10-14 17:06:05 +0200 )edit

Which OS ? Which browser ?

FrédéricC gravatar imageFrédéricC ( 2025-10-14 20:34:17 +0200 )edit