如何在情节中在情节上显示网格

时间:2017-06-05 13:00:01

标签: python-3.x sympy

我想使用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

使用matplotlib可以直接添加网格:

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

Grid using matplotlib

我如何用Sympy做到这一点?

2 个答案:

答案 0 :(得分:2)

如果你有可用的话,SymPy会使用matplotlib, 你可以使用:

from matplotlib import style
style.use('ggplot')

这样会影响你的sympy.plot()

要打印所有可用的样式,请使用:

import matplotlib as plt
print(plt.style.available)

这里为matplotlib的a link about style

答案 1 :(得分:0)

请添加它。

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

您可以这样获得无花果: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))