Overlap scatter plot and curve plot for data fitting

Hi everyone,
I’m trying to do math modeling based on a differential equation. I’m figuring out the parameters that make the graph matched the supported data. In order to see the fitness, I’d like to do overlapping graphs of the plotted curve and the scatter plots. How can I assess it?

p2=plot(sol, xlims=(-1,25),
ylims=(-0.1,1.1),
xticks = 0:4:24,)

p1=scatter(
pulse,
figure6b,
xlims=(-1,25),
ylims=(-0.1,1.1),
xticks = 0:4:24
)
plot!(p1,p2)

The plot! resulted in two adjacent graphs which is not my desired graph.

You can surround your code with triple backticks to make it legible.

To answer your question, your first plot command creates a subplot, p1 = plot(rand(10)). You then want to mutate this subplot to add another series to it: plot!(p1, rand(20)).

You could also create both series in the same call:

plot([[1,2,1] [3,4,5,6]]; seriestype=[:scatter :line])
2 Likes