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

Add subcoordinate_y keyword #1379

Merged
merged 5 commits into from
Aug 5, 2024
Merged

Add subcoordinate_y keyword #1379

merged 5 commits into from
Aug 5, 2024

Conversation

maximlt
Copy link
Member

@maximlt maximlt commented Jul 23, 2024

Closes #1160

  • Add tests
import hvplot.pandas  # noqa
from bokeh.sampledata.sea_surface_temperature import sea_surface_temperature as sst

new_cols = {f'temperature{i}': sst.temperature.shift(i*1000) for i in range(1, 4)}
sst.assign(**new_cols).hvplot(subcoordinate_y=True, legend=False)

image

Copy link

codecov bot commented Jul 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.89%. Comparing base (feffee5) to head (6316666).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1379      +/-   ##
==========================================
+ Coverage   88.87%   88.89%   +0.02%     
==========================================
  Files          51       51              
  Lines        7478     7494      +16     
==========================================
+ Hits         6646     6662      +16     
  Misses        832      832              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@maximlt maximlt requested a review from droumis July 30, 2024 13:22
@droumis
Copy link
Member

droumis commented Aug 5, 2024

Looks pretty good!

Code
import numpy as np
import pandas as pd
from pathlib import Path
import mne
import colorcet as cc
from hvplot import pandas
hv.extension('bokeh')

# data from https://datasets.holoviz.org/eeg/v1/S001R04.edf
data_path = 

raw = mne.io.read_raw_edf(data_path, preload=True)

raw.set_eeg_reference("average")
raw.rename_channels(lambda s: s.strip("."));

df = raw.to_data_frame()
df.set_index('time', inplace=True) 

df.hvplot(subcoordinate_y={'subcoordinate_scale':4}, responsive=True, min_height=700, legend=False, color='black', line_width=1)

image

Known issues:

Nice to haves eventually:

  • apply a color key/cmap based on curve label. for instance, color grouping based first letter of columns:
entries = df.columns.tolist()
colors = cc.b_glasbey_bw
letter_to_color = {letter: colors[i % len(colors)] for i, letter in enumerate(sorted(set(e[0] for e in entries)))}
entry_to_color = {entry: letter_to_color[entry[0]] for entry in entries}
df.hvplot(subcoordinate_y={'subcoordinate_scale':4}, responsive=True, min_height=700, legend=False, line_width=1, cmap=entry_to_color)

Copy link
Member

@droumis droumis left a comment

Choose a reason for hiding this comment

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

made a couple of minor changes

@droumis droumis merged commit dbd62bf into main Aug 5, 2024
@droumis droumis deleted the add_subcoordy_api branch August 5, 2024 18:48
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.

Add HoloViews' subcoordinate_y
2 participants