How to display grid on plot in sympy

Viewed 2387

I would like to display a grid with a plot using Sympy:

import sympy
from sympy import sin
from sympy.abc import x
from math import pi
sympy.plot(sin(x),xlim=(0,2*pi))

Plot using Sympy

Using matplotlib it is straight forward to add a grid :

import matplotlib.pylab as plt
plt.grid(True)
plt.show()

Grid using matplotlib

How can I do this with Sympy?

2 Answers

Please add this.

import seaborn as sns
sns.set()
sns.set_style("whitegrid", {'grid.linestyle': '--'})

You can get fig like this: enter image description here

import sympy
from sympy import sin
from sympy.abc import x
from math import pi
import seaborn as sns
sns.set()
sns.set_style("whitegrid", {'grid.linestyle': '--'})

sympy.plot(sin(x),xlim=(0,2*pi))
Related