朱莉娅:pyplot添加点

朱莉娅:pyplot添加点,plot,julia,Plot,Julia,如何使用pyplot向现有绘图添加单个点 例如,我正在绘制$[0,2\pi]$上的移位sin曲线,如下所示 Pkg.add("PyPlot") using PyPlot r1 = 0; r2 = 2*pi N = 100 t = collect(r1:(r2-r1)/N:r2) fig, ax = subplots() ax[:plot](t, 1+sin(t), linewidth=2.0, color="red",linestyle="--",label="constraint

如何使用
pyplot
向现有绘图添加单个点

例如,我正在绘制$[0,2\pi]$上的移位
sin
曲线,如下所示

Pkg.add("PyPlot")
using PyPlot
r1 = 0; r2 = 2*pi
N = 100
t = collect(r1:(r2-r1)/N:r2)
fig, ax = subplots()
ax[:plot](t, 1+sin(t), 
      linewidth=2.0, color="red",linestyle="--",label="constraint")

我想至少加一个蓝点。我该怎么做?

你可以做
ax[:scatter](1.5π,0,color=“blue”)
或者如果你想在序列中找到一个最小值
s=1+sin(t);pos=findfirst(x->x==最小值,s);ax[:scatter](t[pos],s[pos],color=“blue”)
。实际上使用
indmin
而不是
findfirst
更干净。您可以使用
ax[:scatter](1.5π,0,color=“blue”)
或者如果您想在序列中找到一个最小值
s=1+sin(t);pos=findfirst(x->x==最小值,s);ax[:scatter](t[pos],s[pos],color=“blue”)
。实际上使用
indmin
而不是
findfirst
更干净。