Skip to content

kw alternative #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
t-bltg opened this issue Dec 16, 2022 · 2 comments
Closed

kw alternative #15

t-bltg opened this issue Dec 16, 2022 · 2 comments

Comments

@t-bltg
Copy link
Contributor

t-bltg commented Dec 16, 2022

What is the alternative to

using PyPlot
subplots(subplot_kw=Dict(:aspect=>:equal))

in Pythonplot ?

I tried all sort of Dicts or NamedTuples with Strings or Symbols, but it always error out.

ERROR: Python: TypeError: Cannot convert argument 'value' to a Julia 'String', got a 'NoneType'
Python stacktrace:
 [1] __setitem__
   @ ~/.julia/packages/PythonCall/3GRYN/src/jlwrap/dict.jl:51
 [2] subplots
   @ matplotlib.gridspec [...]/lib/python3.11/site-packages/matplotlib/gridspec.py:306
 [3] subplots
   @ matplotlib.figure [...]/lib/python3.11/site-packages/matplotlib/figure.py:894
 [4] subplots
   @ matplotlib.pyplot [...]/lib/python3.11/site-packages/matplotlib/pyplot.py:1443
Stacktrace:
 [1] pythrow()
   @ PythonCall ~/.julia/packages/PythonCall/3GRYN/src/err.jl:94
 [2] errcheck
   @ ~/.julia/packages/PythonCall/3GRYN/src/err.jl:10 [inlined]
 [3] pycallargs(f::PythonCall.Py, args::PythonCall.Py, kwargs::PythonCall.Py)
   @ PythonCall ~/.julia/packages/PythonCall/3GRYN/src/abstract/object.jl:211
 [4] pycall(::PythonCall.Py; kwargs::Base.Pairs{Symbol, Dict{String, String}, Tuple{Symbol}, NamedTuple{(:subplot_kw,), Tuple{Dict{String, String}}}})
   @ PythonCall ~/.julia/packages/PythonCall/3GRYN/src/abstract/object.jl:222
 [5] #subplots#125
   @ ~/.julia/packages/PythonPlot/3KL1U/src/PythonPlot.jl:181 [inlined]
 [6] top-level scope
   @ REPL[12]:1
@t-bltg
Copy link
Contributor Author

t-bltg commented Dec 16, 2022

Ha, this works: subplots(; subplot_kw=Dict{Any,Any}("aspect"=>"equal")), but it is quite cumbersome ...

@stevengj
Copy link
Member

stevengj commented Dec 16, 2022

Or subplot_kw=PyDict("aspect"=>"equal"))

File an issue with PythonCall if it is not converting dictionaries the way you want.

In general, PythonCall tries harder than PyCall to preserve native Julia objects by default rather than converting them to native Python objects, but this also means that you have to call more explicit conversions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants