# Julia PyPlot equivalent to R's points

**URL:** <https://discourse.julialang.org/t/julia-pyplot-equivalent-to-rs-points/35518>\
**Category:** New to Julia\
**Created:** [March 4, 2020, 1:21pm UTC](https://discourse.julialang.org/t/julia-pyplot-equivalent-to-rs-points/35518 "2020-03-04T13:21:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luigi\_Marongiu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luigi_marongiu/32/7909_2.png) [@Luigi\_Marongiu](https://discourse.julialang.org/u/Luigi_Marongiu)\
**Post date:** [March 4, 2020, 1:21pm UTC](https://discourse.julialang.org/t/julia-pyplot-equivalent-to-rs-points/35518/1 "2020-03-04T13:21:33Z")

</div>

Hello,  
I have a plot with made with PyPlot I would like to customize adding levels of data. The base of the plot is this (the R’s equivalent to the high-level ![relSimulation](https://global.discourse-cdn.com/julialang/original/3X/2/a/2aeb9920733137345eb79adcb51d20740662c27f.png) drawing):  
This was obtained with the call:

```julia
myPlot = plot(soln.t, getindex.(soln.u, 1)+getindex.(soln.u, 2),
    soln.t, getindex.(soln.u, 3))

```

where soln is an the result obtained with DifferentialEquations.jl. To note that the colours are automatic and I defined the legend as `legend(["Bacteria (total)", "Phages"], loc="lower right")`. I then wanted to add some dots on specific locations of the plot so – since I understand that PyPlot does not have the concept of high-level drawing but superimposes plots – I added a second call

```julia
myPlot = plot(soln.t, getindex.(soln.u, 1)+getindex.(soln.u, 2),
    soln.t, getindex.(soln.u, 3))
myPlot = plot(soln_point.t, getindex.(soln_point.u, 1)+getindex.(soln_point.u, 2),
        soln_point.t, getindex.(soln_point.u, 3), marker = "o")

```

where soln\_point is a subset of the previous object; and I obtained:  
 ![relSimulation](https://global.discourse-cdn.com/julialang/original/3X/0/7/074d52e414fa9f4c0c512738147899538df8fb09.png)  
My questions are:  
how can I show only the points?  
Can I show only the contour of the points?  
how can I choose the colour (so that they can match those of the primary plot)? If I add the parameter `, color = ["blue", "orange"]` I get an error when saving the plot.  
Thank you

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [March 4, 2020, 1:31pm UTC](https://discourse.julialang.org/t/julia-pyplot-equivalent-to-rs-points/35518/2 "2020-03-04T13:31:48Z")

</div>

> how can I show only the points?

You’re looking for `scatter` I believe. You then probably want to look at `color` and `markerstrokecolor` (essentially the border of the point)

EDIT: Apologies the `markerstrokecolor` is a Plots.jl kwarg that I think doesn’t actually exist in PyPlot…

---

<div class="post-metadata">

**Author:** ![orialb](https://avatars.discourse-cdn.com/v4/letter/o/65b543/32.png) [@orialb](https://discourse.julialang.org/u/orialb)\
**Post date:** [March 4, 2020, 2:03pm UTC](https://discourse.julialang.org/t/julia-pyplot-equivalent-to-rs-points/35518/3 "2020-03-04T14:03:48Z")

</div>

For plotting only the markers and no line:

```julia
plot(x,y, "o")

```

(or you can specify `marker="o", ls=""` in the code you wrote above)

For choosing the color, at least if you add each set of points in a separate call to plot, you can use

```julia
plot(x,y,"o",color="orange")

```

In general note that PyPlot uses the python `matplotlib` library so you can look things up in `matplotlib`’s documentation.

---

<div class="post-metadata">

**Author:** ![Luigi\_Marongiu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luigi_marongiu/32/7909_2.png) [@Luigi\_Marongiu](https://discourse.julialang.org/u/Luigi_Marongiu)\
**Post date:** [March 4, 2020, 2:07pm UTC](https://discourse.julialang.org/t/julia-pyplot-equivalent-to-rs-points/35518/4 "2020-03-04T14:07:12Z")

</div>

Thank you, how can I provide multiple colours? I can add `color = "red"` but I get an error with `color = ["blue", "green"]`…

---

<div class="post-metadata">

**Author:** ![orialb](https://avatars.discourse-cdn.com/v4/letter/o/65b543/32.png) [@orialb](https://discourse.julialang.org/u/orialb)\
**Post date:** [March 4, 2020, 2:10pm UTC](https://discourse.julialang.org/t/julia-pyplot-equivalent-to-rs-points/35518/5 "2020-03-04T14:10:20Z")

</div>

yeah I am not sure, I have never used the syntax `plot(x1,y1,x2,y2)` for plotting. A simple workaround would be to add each set of points separately:

```julia
plot(soln_points.t, getindex.(soln_points.u, 1)+getindex.(soln_points.u, 2),"o",color="orange")
  
plot(soln_points.t, getindex.(soln_points.u, 3), "o", color="blue")

```

---

<div class="post-metadata">

**Author:** ![Luigi\_Marongiu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luigi_marongiu/32/7909_2.png) [@Luigi\_Marongiu](https://discourse.julialang.org/u/Luigi_Marongiu)\
**Post date:** [March 4, 2020, 2:14pm UTC](https://discourse.julialang.org/t/julia-pyplot-equivalent-to-rs-points/35518/6 "2020-03-04T14:14:52Z")

</div>

OK, thank you. We are almost there:  
 ![relSimulation](https://global.discourse-cdn.com/julialang/original/3X/e/8/e885d8585451c60a815442381596498346ef54dd.png)  
What I miss I the open markers…  
from this [matplotplb site](https://matplotlib.org/3.1.3/api/markers_api.html), looks like there are no open ones… but on this [post](https://stackoverflow.com/questions/4143502/how-to-do-a-scatter-plot-with-empty-circles-in-python), looks like it is possible, only the syntax does not work in Julia…

---

<div class="post-metadata">

**Author:** ![orialb](https://avatars.discourse-cdn.com/v4/letter/o/65b543/32.png) [@orialb](https://discourse.julialang.org/u/orialb)\
**Post date:** [March 4, 2020, 2:19pm UTC](https://discourse.julialang.org/t/julia-pyplot-equivalent-to-rs-points/35518/7 "2020-03-04T14:19:46Z")

</div>

For empty circle markers use `markerfacecolor="None"`  
See [Marker filling-styles — Matplotlib 3.1.3 documentation](https://matplotlib.org/3.1.3/gallery/lines_bars_and_markers/marker_fillstyle_reference.html)

---

<div class="post-metadata">

**Author:** ![Luigi\_Marongiu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luigi_marongiu/32/7909_2.png) [@Luigi\_Marongiu](https://discourse.julialang.org/u/Luigi_Marongiu)\
**Post date:** [March 4, 2020, 2:21pm UTC](https://discourse.julialang.org/t/julia-pyplot-equivalent-to-rs-points/35518/8 "2020-03-04T14:21:51Z")

</div>

Perfect! Thank you!  
 ![relSimulation](https://global.discourse-cdn.com/julialang/original/3X/4/5/45f7612ad9bef12e34a3eeda1eb92b31ef20dfea.png)
