JuliaPy / PythonPlot.jl

Plotting for Julia based on matplotlib.pyplot
MIT License
74 stars 8 forks source link

arrowprops and Dict() #9

Closed PaulSoderlind closed 2 years ago

PaulSoderlind commented 2 years ago

You asked us to report issues...so here is another one: annotate/arrowprops requires an explicit conversion via pydict. Not a big deal, but it differs from PyPlot.

figure()
axis([-4,4,0,0.4])
annotate("there",xy=[0,0.0025],xycoords="data",xytext=[-0.45,0.1],               #fails
         textcoords="data",ha="center",va="top",
         arrowprops=Dict("facecolor"=>"black","width"=>0.5,"headwidth"=>7.0))
#annotate("there",xy=[0,0.0025],xycoords="data",xytext=[-0.45,0.1],              #works
#         textcoords="data",ha="center",va="top",
#         arrowprops=pydict(Dict("facecolor"=>"black","width"=>0.5,"headwidth"=>7.0)))
stevengj commented 2 years ago

Looks like a fixable PythonCall limitation: their Dict wrapper doesn't implement a copy() method. That causes this arrowprops = arrowprops.copy() line in Matplotlib to fail with

ERROR: Python: AttributeError: Julia: type Dict has no field copy
Python stacktrace:
stevengj commented 2 years ago

Closed by https://github.com/cjdoris/PythonCall.jl/commit/a5771962f2a93f8434d78aac6f752db56d131481