# Pyplot: how to change the marker color in a plot?

**URL:** <https://discourse.julialang.org/t/pyplot-how-to-change-the-marker-color-in-a-plot/22599>\
**Category:** Visualization\
**Tags:** pyplot\
**Created:** [April 1, 2019, 2:48pm UTC](https://discourse.julialang.org/t/pyplot-how-to-change-the-marker-color-in-a-plot/22599 "2019-04-01T14:48:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ale](https://avatars.discourse-cdn.com/v4/letter/a/f19dbf/32.png) [@ale](https://discourse.julialang.org/u/ale)\
**Post date:** [April 1, 2019, 2:48pm UTC](https://discourse.julialang.org/t/pyplot-how-to-change-the-marker-color-in-a-plot/22599/1 "2019-04-01T14:48:55Z")

</div>

Hi,

I am trying to plot two curves in the same plot by using `pyplot`.  
I would appreciate if the 2 different curves had different colors. When it comes to the `line`, I managed to change it from the default blue color to e.g. green, by writing:

```julia
 line = (:path, "green")

```

The problem is that I also need markers, but I haven’t managed to change their colour too: no matter the line color, they remain blue (like the default color).  
Any suggestions?  
My code is like:

```julia
# First curve
wanted_font = "garamond"
fig_1 = plot(x_axis_values, y_axis_values, c = [1], # I added c=[1] to not get a warning message, as suggested in another post/forum, I'm not sure about the meaning
title = "My title",
titlefont = wanted_font, tickfont = wanted_font, legendfont = wanted_font, guidefont = wanted_font,
xlabel = "Year", ylabel = "Magnitude",
legend = true, legend = :topleft,
label = "Trend in scenario 1",
grid = false,
marker = (:circle, 4),
)

# Second curve
plot!(fig_1, x_axis_values, second_y_axis_values,
c = [1], # I added c=[1] to not get a warning message, as suggested in another post/forum, I'm not sure about the meaning
label = "Trend in scenario 2",
line = (:path, "green"), # Here I change the line color
marker = (:diamond, 4), 
# Missing: something to change the marker color too ....
)

```

Thank you in advance!

---

<div class="post-metadata">

**Author:** ![purplishrock](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/purplishrock/32/13451_2.png) [@purplishrock](https://discourse.julialang.org/u/purplishrock)\
**Post date:** [April 1, 2019, 3:35pm UTC](https://discourse.julialang.org/t/pyplot-how-to-change-the-marker-color-in-a-plot/22599/2 "2019-04-01T15:35:11Z")

</div>

Remember that pyplot is matplotlib, so you can simply search on matplotlib + marker color

[https://matplotlib.org/api/\_as\_gen/matplotlib.pyplot.plot.html?highlight=plot#matplotlib.pyplot.plot](https://matplotlib.org/api/_as_gen/matplotlib.pyplot.plot.html?highlight=plot#matplotlib.pyplot.plot)

looks like you can define marker face color, edge color, etc… so it depends on what you want to do.

e.g.

```julia
plot(1:10,1:10,"o", markerfacecolor="g")

```

---

<div class="post-metadata">

**Author:** ![ale](https://avatars.discourse-cdn.com/v4/letter/a/f19dbf/32.png) [@ale](https://discourse.julialang.org/u/ale)\
**Post date:** [April 7, 2019, 5:24pm UTC](https://discourse.julialang.org/t/pyplot-how-to-change-the-marker-color-in-a-plot/22599/3 "2019-04-07T17:24:12Z")

</div>

@purplishrock thanks for your reply.  
However, I tried:

```julia
using Plots
pyplot()

plot(1:10,1:10,"o", markerfacecolor="g")

```

And I get the following error:

```julia
ERROR: No user recipe defined for String
Stacktrace:
 [1] macro expansion at C:\Users\username\.julia\v0.6\Plots\src\series.jl:133 [inlined]
 [2] apply_recipe(::Dict{Symbol,Any}, ::Type{Plots.SliceIt}, ::UnitRange{Int64}, ::UnitRange{Int64}, ::String) at C:\Users\username\.julia\v0.6\RecipesBase\src\RecipesBase.jl:291
 [3] _process_userrecipes(::Plots.Plot{Plots.PyPlotBackend}, ::Dict{Symbol,Any}, ::Tuple{UnitRange{Int64},UnitRange{Int64},String}) at C:\Users\username\.julia\v0.6\Plots\src\pipeline.jl:81
 [4] _plot!(::Plots.Plot{Plots.PyPlotBackend}, ::Dict{Symbol,Any}, ::Tuple{UnitRange{Int64},UnitRange{Int64},String}) at C:\Users\username\.julia\v0.6\Plots\src\plot.jl:179
 [5] #plot#212(::Array{Any,1}, ::Function, ::UnitRange{Int64}, ::Vararg{Any,N} where N) at C:\Users\username\.julia\v0.6\Plots\src\plot.jl:58
 [6] (::RecipesBase.#kw##plot)(::Array{Any,1}, ::RecipesBase.#plot, ::UnitRange{Int64}, ::UnitRange{Int64}, ::Vararg{Any,N} where N) at .\<missing>:0
 [7] macro expansion at C:\Users\username\.julia\v0.6\Atom\src\repl.jl:118 [inlined]
 [8] anonymous at .\<missing>:?

```

Any explanation?

---

<div class="post-metadata">

**Author:** ![purplishrock](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/purplishrock/32/13451_2.png) [@purplishrock](https://discourse.julialang.org/u/purplishrock)\
**Post date:** [April 7, 2019, 5:28pm UTC](https://discourse.julialang.org/t/pyplot-how-to-change-the-marker-color-in-a-plot/22599/4 "2019-04-07T17:28:19Z")

</div>

You are using Plots and I always specifically use Pyplot, i.e.

```julia
using PyPlot

```

I didn’t notice that you were using the Plots package in your example.  
You need to consult the Plot package documentation, it will have a different interface.  
I took a (very) quick look at the Plots documentation and it looks like

```julia
markercolor = :green

```

should do what you want.
