Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Using px.density_contour with both marginal_x and contours_coloring causes error #175

Open
adamerose opened this issue Jun 28, 2021 · 2 comments

Comments

@adamerose
Copy link

adamerose commented Jun 28, 2021

I get the error below when trying to add marginal_x to the "continuously-colored and labeled" example on this page https://plotly.com/python/2d-histogram-contour/

import plotly.express as px

df = px.data.tips()

fig = px.density_contour(df, x="total_bill", y="tip", marginal_x='box')
fig.update_traces(contours_coloring="fill", contours_showlabels=True)
"C:\Program Files\Python38\python.exe" D:/_MyFiles/Programming/scratch/scratch.py
Traceback (most recent call last):
  File "D:/_MyFiles/Programming/scratch/scratch.py", line 6, in <module>
    fig.update_traces(contours_coloring="fill", contours_showlabels=True)
  File "C:\Program Files\Python38\lib\site-packages\plotly\basedatatypes.py", line 1376, in update_traces
    trace.update(patch, overwrite=overwrite, **kwargs)
  File "C:\Program Files\Python38\lib\site-packages\plotly\basedatatypes.py", line 5067, in update
    BaseFigure._perform_update(self, kwargs, overwrite=overwrite)
  File "C:\Program Files\Python38\lib\site-packages\plotly\basedatatypes.py", line 3862, in _perform_update
    raise err
ValueError: Invalid property specified for object of type plotly.graph_objs.Box: 'contours'

...

Bad property path:
contours_coloring
^^^^^^^^
@john-verran
Copy link

@adamerose did you ever find a solution or workaround for this?

@adamerose
Copy link
Author

@john-verran Nope haven't revisited this since I first made the issue, it's a pretty specific graph and I haven't personally had the need to find a workaround.

But in general when I run into a roadblock with plotly express for something important the workaround is to rebuild it from scratch using the base Plotly API, it's never failed me before but takes more effort. I would start here https://plotly.com/python/contour-plots/ and then add the histograms with shared axes like this https://plotly.com/python/subplots/#subplots-with-shared-xaxes

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

No branches or pull requests

2 participants