- 按照this answer的重复,在Inline模式下,必须使用
p.backend(p)
.
- The problem is that 100 creates its own figure and axes和
plots.show()
立即显示绘图.
- 由于内联模式的工作方式,绘图在
ax.set_yticks((0, .05, .25))
实施更改之前显示.
- Tested in 100, 101, 102.
from sympy import symbols, plot
import matplotlib.pyplot as plt
x = symbols('x')
# note show=False, the default is True
p = plot(x, x*(1-x), (x, 0, 1), show=False)
fig, ax = plt.subplots()
backend = p.backend(p)
backend.ax = ax
backend._process_series(backend.parent._series, ax, backend.parent)
backend.ax.set_yticks((0, .05, .25))
plt.close(backend.fig)
plt.show()
- 在交互模式
%matplotlib qt
中,OP中的代码工作正常.
from sympy import symbols, plot
import matplotlib.pyplot as plt
%matplotlib qt # %matplotlib inline - to revert to inline
x = symbols('x')
p = plot(x, x*(1-x), (x, 0, 1))
ax = p._backend.ax[0]
ax.set_yticks((0, .05, .25))