# Modifying legend markersize/linelength of a Plots/PyPlot plot after creation

**URL:** <https://discourse.julialang.org/t/modifying-legend-markersize-linelength-of-a-plots-pyplot-plot-after-creation/36723>\
**Category:** Visualization\
**Created:** [March 30, 2020, 9:03am UTC](https://discourse.julialang.org/t/modifying-legend-markersize-linelength-of-a-plots-pyplot-plot-after-creation/36723 "2020-03-30T09:03:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dapz](https://avatars.discourse-cdn.com/v4/letter/d/a4c791/32.png) [@dapz](https://discourse.julialang.org/u/dapz)\
**Post date:** [March 30, 2020, 9:03am UTC](https://discourse.julialang.org/t/modifying-legend-markersize-linelength-of-a-plots-pyplot-plot-after-creation/36723/1 "2020-03-30T09:03:25Z")

</div>

Hi, I’m using a lot Plots.jl as I like having the common interface, but right now using mostly the PyPlot backend. I don’t want to use directly PyPlot as I coded some Plots recipes that I use.  
I have trouble with the legend (the markers in the legend are too large, so that we cannot see the linestyles below, e.g. cannot distinguish a solid line and a dashed line if there are square markers symbols superimposed).  
As I cannot find such options in Plots attributes, I though I could as a workaround access the PyPlot object and modify it.  
So I tried something like (where `p` is the plot produced by Plots)

```julia
for ax in p.o.axes
	hdl = p.o.legend().legendHandles
	for ln in hdl
		if :_legmarker in keys(ln)
			ln._legmarker.set_markersize(2)
		end
	end
end

```

but it doesn’t work at all (the code runs, but doesn’t look to do anything).  
Is there a difference between accessing `p.o` or using directly the PyPLot interface with e.g. `gcf`? Is it ok to modify a figure like that after creation?  
On my exported figure (I export after in pgf format), many settings such as the figure size are changed… I ideally would like to modify just the legend and keep the rest intact.

Any idea how to solve that, or a workaround?
