# How to set markers in julia pyplot's legend?

**URL:** <https://discourse.julialang.org/t/how-to-set-markers-in-julia-pyplots-legend/71527>\
**Category:** Visualization\
**Tags:** question, package, pyplot\
**Created:** [November 15, 2021, 9:02pm UTC](https://discourse.julialang.org/t/how-to-set-markers-in-julia-pyplots-legend/71527 "2021-11-15T21:02:43Z")\
**Posts on this page:** 2\
**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:** [November 15, 2021, 9:02pm UTC](https://discourse.julialang.org/t/how-to-set-markers-in-julia-pyplots-legend/71527/1 "2021-11-15T21:02:44Z")

</div>

Hello,  
I plotted some data with lines and then highlighted some specific points with dots using PyPlot. When I add the legend, the icons next to the names only shows line because the first elements of the plot are indeed lines. Can I add manually the shapes of the markers? I tried adding the parameter `marker` but gave an error.  
This is the figure

 ![CASE_3growth](https://global.discourse-cdn.com/julialang/original/3X/9/e/9ef57a2633161789e486a79ade3b138d572bbba1.png)

and this is the code for the legend:

```julia
julia> legend(["S. mutans (alone)", "C. albicans (alone)",
           "S. mutans (together)", "C. albicans (together)"],
           marker = ["o", "o", "o", "o"],
           loc="lower right")
ERROR: PyError ($(Expr(:escape, :(ccall(#= ~/.julia/packages/PyCall/3fwVL/src/pyfncall.jl:43 =# @pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))) <class 'TypeError'>
TypeError(" __init__ () got an unexpected keyword argument 'marker'")
  File "/usr/lib/python3/dist-packages/matplotlib/pyplot.py", line 2738, in legend
    return gca().legend(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/matplotlib/axes/_axes.py", line 417, in legend
    self.legend_ = mlegend.Legend(self, handles, labels, **kwargs)

```

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [November 16, 2021, 1:19pm UTC](https://discourse.julialang.org/t/how-to-set-markers-in-julia-pyplots-legend/71527/2 "2021-11-16T13:19:17Z")

</div>

You could consider a two-step approach as in this quick and dirty example:

```julia
using PyPlot
x = 0:0.3:π; y1 = sin.(x); y2 = cos.(x)
PyPlot.plot(x,y1,linestyle="-", color="blue", label="")
PyPlot.plot(x,y2,linestyle="--", color="red", label="")
ix = 1:3
PyPlot.plot(x[ix],y1[ix],linestyle="-",marker="o", color="blue", label="Curve-1")
PyPlot.plot(x[ix],y2[ix],linestyle="--", color="red", marker="o", label="Curve-2")
legend(loc="upper right",fancybox="true")

```

![PyPlot_partial_line_markers_and_legend](https://global.discourse-cdn.com/julialang/original/3X/3/1/318f9af7ce2648b636127c228771786c587b2246.png)
