holoviz / holoviz/hvplot

Overlays should respect the first x/y dimensions or raise an error

Open
#1,413 0 comments 0 reactions 0 assignees View on GitHub
TRIAGE
Dominant language
Python
Stars
1.4k
Forks
124
Avg merge
1d 18h
Merged PRs (30d)
1

Description

Not sure if this is a hvplot issue or holoviews issue, and the example could probably be simplified by transposing a simple xy df

If I don't specify x, y kwargs manually, I get:

image

If I specify x,y kwargs, I get:
image

```python
import numpy as np
import pandas as pd
import xarray as xr

import datashader as ds

from datashader.transfer_functions import shade
from datashader.transfer_functions import stack
from datashader.transfer_functions import dynspread
from datashader.transfer_functions import set_background
from datashader.colors import Elevation

import xrspatial
from xrspatial import viewshed

OBSERVER_X = -12.5
OBSERVER_Y = 10

canvas = ds.Canvas(plot_width=W, plot_height=H, x_range=(-20, 20), y_range=(-20, 20))

normal_df = pd.DataFrame(
{"x": np.random.normal(0.5, 1, 10000000), "y": np.random.normal(0.5, 1, 10000000)}
)
normal_agg = canvas.points(normal_df, "x", "y")
normal_agg.values = normal_agg.values.astype("float64")
normal_shaded = shade(normal_agg)

observer_df = pd.DataFrame({"x": [OBSERVER_X], "y": [OBSERVER_Y]})
observer_agg = canvas.points(observer_df, "x", "y")
observer_shaded = dynspread(shade(observer_agg, cmap=["orange"]), threshold=1, max_px=4)

normal_illuminated = hillshade(normal_agg)
normal_illuminated_shaded = shade(
normal_illuminated, cmap=["black", "white"], alpha=128, how="linear"
)

stack(normal_illuminated_shaded, observer_shaded)

# Will take some time to run...
view = viewshed(normal_agg, x=OBSERVER_X, y=OBSERVER_Y)

view_shaded = shade(view, cmap=["white", "red"], alpha=128, how="linear")

normal_illuminated.hvplot("x", "y") * view.hvplot(
"x", "y", cmap=["yellow", "black"], alpha=0.5
) * observer_df.hvplot.points("x", "y", color="red")
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.