Julia PyPlot equivalent to R's points

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-levelrelSimulation drawing):
This was obtained with the call:

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

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
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

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…

For plotting only the markers and no line:

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

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.

1 Like

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

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:

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")

OK, thank you. We are almost there:
relSimulation
What I miss I the open markers…
from this matplotplb site, looks like there are no open ones… but on this post, looks like it is possible, only the syntax does not work in Julia…

For empty circle markers use markerfacecolor="None"
See Marker filling-styles — Matplotlib 3.1.3 documentation

Perfect! Thank you!
relSimulation