Skip to main content

Plotly graph for labelling timeserie data

Project description

streamlit-label-graph

Plotly graph for labelling timeserie data

pip install streamlit-label-graph
import streamlit as st

import pandas as pd
import numpy as np
import plotly.express as px
import plotly.graph_objects as go
from plotly.subplots import make_subplots

from streamlit_label_graph import label_graph, LabelConfig


@st.cache_data
def weather_data ():
    x = pd.date_range(start='2022-01-01', end='2022-12-31', freq='D')
    y = np.sin(2 * np.pi * x.dayofyear / 365) + np.random.normal(0, 0.1, size=len(x))
    return pd.DataFrame({'date': x, 'temperature': y})

config: LabelConfig = {
    'categories': [
        {'key': 'HOT', 'color': 'rgba(255 110 110,0.1)'},
        {'key': 'COLD', 'color': 'rgba(110,110,255,0.1)'}
    ]
}
df = weather_data()

figure = px.line(df, x=df['date'], y=df['temperature'])
labels = label_graph(figure, config)
df['label'] = labels['series']

fig = make_subplots(specs=[[{"secondary_y": True}]])
fig.add_trace(go.Line(x=df['date'], y=df['temperature'], name='temperature'), secondary_y=False)
fig.add_trace(go.Line(x=df['date'], y=df['label'], name='label'), secondary_y=True)
st.write(fig)
st.write(labels)
  • Use Ctrl + Mouse-drag to create a new label
  • Right click on a label to set the category

Demo

Run demo

python -m streamlit_label_graph

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streamlit-label-graph-0.1.2.tar.gz (63.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

streamlit_label_graph-0.1.2-py3-none-any.whl (64.8 kB view details)

Uploaded Python 3

File details

Details for the file streamlit-label-graph-0.1.2.tar.gz.

File metadata

  • Download URL: streamlit-label-graph-0.1.2.tar.gz
  • Upload date:
  • Size: 63.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for streamlit-label-graph-0.1.2.tar.gz
Algorithm Hash digest
SHA256 846cd3f4427af765eecabdd3831882c0d5dc4c5baf40833c99362d06bcebf18f
MD5 bd89fc01dfcbce89008a0d2d8d8cd967
BLAKE2b-256 8b93b9487ff3604f23440b33fccf9e8a0ce03b9f95dd4304a0e7e9a0a519110c

See more details on using hashes here.

File details

Details for the file streamlit_label_graph-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_label_graph-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fd68ade0421ba0e894353f92b0060d373cd0109388eef61d9af0e76f16f4d756
MD5 87d1e4364ef905c9f78e54cf83211790
BLAKE2b-256 ebec85cc35fbdce6b9287699a46ffcd29e4e342cac513e260b4e46961686fb27

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page