JuliaPy / PyPlot.jl

Plotting for Julia based on matplotlib.pyplot
https://github.com/JuliaPy/PyPlot.jl
MIT License
475 stars 87 forks source link

Setting rcParams fails silently #417

Closed hsgg closed 5 years ago

hsgg commented 5 years ago

I am unable to set matplotlib parameters via rcParams, e.g.

julia> using PyPlot

julia> matplotlib[:rcParams]["font.size"] = 15.0
15.0

julia> matplotlib[:rcParams]["font.size"]
10.0

This is in contrast to the equivalent code in python, which does allow me to change the font size in this manner. I find this difference in behavior surprising.

Judging by other bug reports (e.g. #114, #309), I believe this to be a regression introduced within the last year or so. (Explicitly converting rcParams to a PyDict() as in those reports doesn't make it work, either.)

On the other hand, using rc works, e.g.

julia> matplotlib[:rc]("font", size=15.0)

julia> matplotlib[:rcParams]["font.size"]
15.0
MaxandreJ commented 5 years ago

From memory, I've experienced the same issue.

stevengj commented 5 years ago

That's because matplotlib[:rcParams] currently makes a copy of the dictionary (this is the default in PyCall).

You want

rcParams = PyDict(matplotlib["rcParams"])
rcParams["font.size"] = 15