如何使用 Sympy 图在某些 x 坐标处添加标记

How to add markers at certain x coordinates using Sympy plot

我有一个 Sympy 函数、一个 x 坐标序列和一个使用“plot”绘制的图形。

import numpy as np
import sympy as sp

x = sp.Symbol('x')
xs = np.linspace(-2, 3, 5) #[-2.   -0.75  0.5   1.75  3.  ]
ys = sp.cos(2*x)*(sp.sin(2*x) + 1.5)+sp.cos(x)
graph = sp.plot(ys, xlim=[-2,3])

如何在 xs 变量的 X 坐标处的函数上绘制标记?

我得到的图表:

我想得到的图表:

Sympy 的阴谋. This is a list of dictionaries towards matplotlib's plot。 Sympy 的 subs 可用于将 x 值填充到公式中。

import numpy as np
import sympy as sp

x = sp.Symbol('x')
y = sp.Symbol('y')
ys = sp.cos(2 * x) * (sp.sin(2 * x) + 1.5) + sp.cos(x)

xs = np.linspace(-2, 3, 5)  # [-2.   -0.75  0.5   1.75  3.  ]
yvals = [ys.subs(x, xi) for xi in xs]

plot = sp.plot(ys, xlim=[-2.2, 3.2],
               markers=[{'args': [xs, yvals, 'ro']}])