1

When I make a normal hvplot with a groupby it creates a DynamicMap where the y-axis changes when I select a different value in my dropdown. This is the behavior I want.

However when I set datashade=True (with large data) the y-axis stays fixed, which is unhandy when I select a different value in the dropdown. I want my y-axis to change automatically when I select a different value in the dropdown.

See the example below:

# import libraries
import numpy as np
import pandas as pd

import hvplot
import hvplot.pandas

import holoviews as hv
hv.extension('bokeh')

# create sample data
col1 = np.random.normal(loc=0.0, size=[50, ])
col2 = np.random.normal(loc=300.0, size=[50, ])

df = pd.DataFrame(data={'col1': col1, 'col2': col2}).melt()

# argument datashade=True causes that y-axis isn't automatically updated, which I would like it to be
df.hvplot(kind='scatter', x='index', y='value', groupby='variable', dynspread=True, datashade=True)

datashade True causes y-axis not to be updated in hvplot

Sander van den Oord
  • 10,986
  • 5
  • 51
  • 96

1 Answers1

0

Just add .opts(framewise=True) to the result from hvplot, to make it normalize each frame independently in all cases:

df.hvplot(kind='scatter', x='index', y='value', groupby='variable', dynspread=True, datashade=False).opts(framewise=True)
James A. Bednar
  • 3,195
  • 1
  • 9
  • 13
  • Hi James, unfortunately this doesnt work: it works when you only switch from col1 to col2 and never switch again. But if you switch now back to col1, the y-axis is now stuck with the y-range from col2. Is this a bug? – Sander van den Oord Oct 01 '19 at 13:45
  • Yes, that does look like a bug; see https://github.com/pyviz/hvplot/issues/322 . Thanks for filing it. – James A. Bednar Oct 01 '19 at 19:34