# Overlap scatter plot and curve plot for data fitting

**URL:** <https://discourse.julialang.org/t/overlap-scatter-plot-and-curve-plot-for-data-fitting/64128>\
**Category:** Tooling\
**Tags:** plotting\
**Created:** [July 6, 2021, 5:38am UTC](https://discourse.julialang.org/t/overlap-scatter-plot-and-curve-plot-for-data-fitting/64128 "2021-07-06T05:38:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![minhnguyen](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@minhnguyen](https://discourse.julialang.org/u/minhnguyen)\
**Post date:** [July 6, 2021, 5:38am UTC](https://discourse.julialang.org/t/overlap-scatter-plot-and-curve-plot-for-data-fitting/64128/1 "2021-07-06T05:38:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [July 6, 2021, 5:45am UTC](https://discourse.julialang.org/t/overlap-scatter-plot-and-curve-plot-for-data-fitting/64128/2 "2021-07-06T05:45:53Z")

</div>

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:

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

```
