brunorosilva / plotly-calplot

The easiest and best looking Calendar Heatmap you'll find, made with Plotly.
https://pypi.org/project/plotly-calplot/
104 stars 10 forks source link

Legend with years with different maximum densities #4

Closed ghhar98 closed 2 years ago

ghhar98 commented 2 years ago

I'm trying to make a calendar heatmap with years with different distributions, and it causes problems with the legend, as one can see in the screenshot.

image

As we can see, the high density number of event is different depending on the year, which causes problem.

This is the code i'm using : image

Thank you.

brunorosilva commented 2 years ago

That's a problem I hadn't think about. Thanks for bringing it up and I'll work on setting a global colorscale as default.

In the meantime you can add zmin and zmax to set the colorscale values as globals for all years.

If you know what the max and min values possible are, then use

fig.update_traces(
    showscale = True, 
    selector=dict(type='heatmap'),
    zmax=max_possible_value, # like 10 or 20
    zmin=min_possible_value # like zero
)

If they vary from user to user user

fig.update_traces(
    showscale = True, 
    selector=dict(type='heatmap'),
    zmax=df["count"].max(),
    zmin=df["count"].min() # or zero
)
brunorosilva commented 2 years ago

Just published a new version addressing this issue by adding a colorscale parameter and forcing the zmax of the colorscale to the global maximum of the dataframe.