Open jamaa opened 1 year ago
Thanks @jamaa - certainly makes sense to want to do this, but I think the problem is make_subplots
stores some extra info in the Python objects that don’t correspond to anything in plotly.js, so are not reflected in the JSON we send to the browser. @nicolaskruchten is there anything you can suggest to put that info back, or any way we could potentially infer what it must have been?
is there any other way to add traces to subplots of an existing figure passed by a callback?
Under the hood row=r, col=c
gets turned into go.Scatter(..., xaxis="x<m>", yaxis="y<n>")
- the challenge is just to figure out what <m>
and <n>
are for a given r
and c
, and if layout.xaxis<m>
and layout.yaxis<n>
don't exist they also need to be created with the proper domain
set. So if you make sure that all the necessary subplots have something in them from the beginning, all you'd need to do is find the right axis numbers, otherwise it becomes more complicated.
Hi - we are tidying up stale issues and PRs in Plotly's public repositories so that we can focus on things that are most important to our community. If this issue is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. (Please note that we will give priority to reports that include a short reproducible example.) If you'd like to submit a PR, we'd be happy to prioritize a review, and if it's a request for tech support, please post in our community forum. Thank you - @gvwilson
yes, the issue still persists, just tested it using the minimal example above with plotly v5.23.0
Describe your context
Describe the bug I am trying to update a plotly figure containing subplots within a dash callback but get the error "Exception: Use plotly.tools.make_subplots to create a subplot grid".
The
Figure
object is passed as aState
to the callback function. Because the figure is passed to the callback function as a dict, I usefig =pio.from_json(json.dumps(fig))
to convert it back to a properFigure
object. However, after conversion, thisFigure
object does not seem to know about its subplots anymore, raising the following exception whenever I try to reference anything subplot-related, e.g.fig.print_grid()
orfig.add_trace([...], row=2, col=1)
:Minimal code to reproduce:
Full example app:
Expected behavior I expect to be able to access the subplots of the figure in the callback method.