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

Make rescale_discrete_levels a plot option #758

Merged
merged 7 commits into from
Jul 27, 2022

Conversation

maximlt
Copy link
Member

@maximlt maximlt commented May 18, 2022

It was a datashader operation option, it's now a plot option that has no default value, like cnorm.

I assumed holoviz/holoviews#5268 would be merged, setting rescale_discrete_levels to True by default in the shader operation. If not, and if the intent is to have it set by default to True in hvPlot but not in HoloViews (I'd prefer them having the same default), this PR will have to be adapted.

import numpy as np, pandas as pd
import hvplot.pandas

def random_walk(n, f=5000):
    """Random walk in a 2D space, smoothed with a filter of length f"""
    xs = np.convolve(np.random.normal(0, 0.1, size=n), np.ones(f)/f).cumsum()
    ys = np.convolve(np.random.normal(0, 0.1, size=n), np.ones(f)/f).cumsum()
    xs += 0.1*np.sin(0.1*np.array(range(n-1+f))) # add wobble on x axis
    xs += np.random.normal(0, 0.005, size=n-1+f) # add measurement noise
    ys += np.random.normal(0, 0.005, size=n-1+f)
    return np.column_stack([xs, ys])

paths = random_walk(2000,30)
df = pd.DataFrame(paths, columns=['x', 'y'])

df.hvplot.paths(x='x', y='y', aspect=1, datashade=True, cnorm='eq_hist') + \
df.hvplot.paths(x='x', y='y', aspect=1, rasterize=True, cnorm='eq_hist')

image

Copy link
Member

@jbednar jbednar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I think this is ready to merge, along with the corresponding HoloViews PR.

@maximlt maximlt added this to the 0.8.1 milestone Jul 18, 2022
@philippjfr philippjfr merged commit 0888a18 into master Jul 27, 2022
@philippjfr philippjfr deleted the rescale_discrete_values branch July 27, 2022 15:47
@philippjfr
Copy link
Member

Thanks!

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 this pull request may close these issues.

3 participants