install plotly in streamlit code example
Example: plotly express in streamlit
import streamlit as st
import pandas as pd
import plotly.express as px
@st.cache()
def load_data():
df = pd.read_csv(
'https://github.com/chris1610/pbpython/blob/master/data/cereal_data.csv?raw=True'
)
return df
df = load_data()
st.title('Rating exploration')
x_options = [
'calories', 'protein', 'fat', 'sodium', 'fiber', 'carbo', 'sugars',
'potass'
]
x_axis = st.sidebar.selectbox('Which value do you want to explore?', x_options)
fig = px.scatter(df,
x=x_axis,
y='rating',
hover_name='name',
title=f'Cereal ratings vs. {x_axis}')
st.plotly_chart(fig)