Spaces:
Sleeping
Sleeping
File size: 617 Bytes
d471ad5 6bdebc7 d471ad5 6bdebc7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import streamlit as st
import altair as alt
import pandas as pd
# Generate random data for the chart
data = pd.DataFrame({
'Category': ['A', 'B', 'C', 'D', 'E'],
'Value': [0.2, 0.5, 0.8, 1.2, 1.5]
})
# Define the color scale for the bars
color_scale = alt.Scale(
domain=[0, 1], # Values between 0 and 1 will be blue
range=['steelblue', 'lightgray']
)
# Create the bar chart using Altair
chart = alt.Chart(data).mark_bar().encode(
x='Category',
y='Value',
color=alt.Color('Value', scale=color_scale)
)
# Render the chart using Streamlit
st.altair_chart(chart, use_container_width=True) |