Skip to content
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

Manually Change min and max Value #18

Open
soerenetler opened this issue Jan 17, 2023 · 7 comments · Fixed by #20
Open

Manually Change min and max Value #18

soerenetler opened this issue Jan 17, 2023 · 7 comments · Fixed by #20

Comments

@soerenetler
Copy link

Hello again,
When using calplot I notice that the min value of the heatmap is fixed to 0 und the max value is fixed to the highest datapoint in the column. It would be great to manually change these values to e.e. allow for negative number and change the maximum value e.g. from 980 in the dataset to 1000 to make the scale easier to understand.
This is currently not possible or did I miss anything.
thank you for your work again and all the best,
Sören

@brunorosilva
Copy link
Owner

Hi, that's true. It's not currently possible to assign a min value. I'll work on this ASAP.

@soerenetler
Copy link
Author

Amazing! If you want I could also take a look. Sounds like a good first issue to solve :)

@OmniaData
Copy link

OmniaData commented Mar 19, 2023

Hi Bruno, great package; as soon as I saw it I thought it would be great for visualising the return on public transport usage for my dissertation. However, a lot of the data I'm looking at has movement from a zero baseline either in the positive and negative direction.

As Sören pointed out, it would be great to be able to visualise -ve to +ve values or set the min and max range.

Looking forward to the update!

Chris

@brunorosilva
Copy link
Owner

brunorosilva commented Mar 23, 2023

Hi @soerenetler and @OmniaData , I'll be adding this feature in the next release.

I'd be happy to hear some opinions.

import numpy as np
import pandas as pd

from plotly_calplot.calplot import calplot, month_calplot

# mock setup
dummy_start_date = "2019-01-01"
dummy_end_date = "2022-10-03"
dummy_df = pd.DataFrame(
    {
        "ds": pd.date_range(dummy_start_date, dummy_end_date),
        "value": np.random.randint(
            0,
            30,
            (pd.to_datetime(dummy_end_date) - pd.to_datetime(dummy_start_date)).days
            + 1,
        ),
    }
)
fig1 = calplot(
    dummy_df,
    x="ds",
    y="value",
    showscale=True,
    cmap_max=20,
    cmap_min=10
)

image


fig1 = calplot(
    dummy_df,
    x="ds",
    y="value",
    showscale=True,
    cmap_max=50
)

image

fig1 = calplot(
    dummy_df,
    x="ds",
    y="value",
    showscale=True,
    cmap_max=25,
    cmap_min=-10,
    colorscale="rdylgn"
)

image

@OmniaData
Copy link

That's fantastic, Bruno. Looking forward to it!

I do prefer manually setting min and max values; however, for end-user experience, I would suggest the option to auto scale min and max based on the dataframe values.

I've also been using arcGIS the last few days. A cool feature they have on mapping colours is the ability to choose from natural breaks (Jenks), equal interval, and quantiles. Additionally, you are able to select the number of classes (last image) that the colour steps are broken in to. No pressure to add it as a feature, but it may be something that you'd like to check out for the future.

image

If you are interested, more information can be found here:

@brunorosilva
Copy link
Owner

@OmniaData that's awesome. I've been looking for something like the natural breaks algorithm for a while, just didn't know how to phrase it correctly.

I should've been clearer, I've added auto scaling by default based on the dataframe min and max values and added the cmap_max and cmap_min as optional params.

@brunorosilva brunorosilva mentioned this issue Mar 27, 2023
@brunorosilva brunorosilva linked a pull request Mar 27, 2023 that will close this issue
@brunorosilva brunorosilva reopened this Mar 27, 2023
@brunorosilva
Copy link
Owner

I'll leave this issue open so these references won't get lost.

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

Successfully merging a pull request may close this issue.

3 participants