Field between 3 functions

asked 2019-11-21 15:48:39 -0600

updated 2019-11-25 05:49:24 -0600

Iguananaut gravatar image

What need to change in that code because it doesn't work? In python it works good but in Sage show error.

import matplotlib.pyplot as plt
import numpy as np
x = np.arange(-5, 3, 0.01)
y_1 = 4 - x ** 2
y_2 = 3 * x
y_3 = x*0 + 3
y_4 = np.minimum(y_1, y_3)
plt.fill_between(x, y_2, y_4, where=y_2<=y_4, color='grey', alpha='0.5')
plt.plot(x, y_1, 'r')
plt.plot(x, y_2, 'b')
plt.plot(x, y_3, 'g')
plt.show()

In Notebook, Sage 8.9, Ubuntu image description

edit retag flag offensive close merge delete

Comments

but maybe your question is about SageMath in the terminal? .in this case sorry I do not know how to print a figure in the terminal.

ortollj gravatar imageortollj ( 2019-11-22 07:07:41 -0600 )edit

could you precise the OS, the Sagemath version, notebook or terminal please ?

ortollj gravatar imageortollj ( 2019-11-22 11:23:30 -0600 )edit

I don't know how to change this code to work in Sagemath Notebook because when I paste this code it doesn't work and I saw errors..

precelina gravatar imageprecelina ( 2019-11-23 06:41:19 -0600 )edit

Could you copy/paste the full error message that you obtain in the notebook?

vdelecroix gravatar imagevdelecroix ( 2019-11-23 13:12:18 -0600 )edit

Maybe you can show us the errors you got, like @vdelecroix asked you ?

ortollj gravatar imageortollj ( 2019-11-24 02:57:38 -0600 )edit