Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
write a streamlit program that generates a graphical emotion wheel that can animate a spin. With the animated emotion wheel, display it as a pie graph sunburst plot with an emoji for each of the emotions including: love, fear, anger, sadness, happiness, surprise, disgust, and love.
|
2 |
+
|
3 |
+
import streamlit as st
|
4 |
+
import pandas as pd
|
5 |
+
import numpy as np
|
6 |
+
import plotly.express as px
|
7 |
+
import matplotlib.pyplot as plt
|
8 |
+
import seaborn as sns
|
9 |
+
|
10 |
+
# Create an emotion wheel
|
11 |
+
emotions = ["Love", "Fear", "Anger", "Sadness", "Happiness", "Surprise", "Disgust", "Love"]
|
12 |
+
emoji = ["❤️", "😱", "😠", "😢", "🤩", "😮", "🤢", "❤️"]
|
13 |
+
|
14 |
+
# Add the wheel to the sidebar
|
15 |
+
st.sidebar.title("Emotion Wheel")
|
16 |
+
st.sidebar.radio("Choose an emotion", emotions)
|
17 |
+
|
18 |
+
# Create a sunburst chart
|
19 |
+
df = pd.DataFrame({"emotion": emotions, "emoji": emoji})
|
20 |
+
fig = px.sunburst(df, values="emoji", path=["emotion"], color="emoji")
|
21 |
+
|
22 |
+
# Plot the chart
|
23 |
+
st.plotly_chart(fig, use_container_width=True)
|
24 |
+
|
25 |
+
# Add an animation button
|
26 |
+
animation_button = st.button("Animate")
|
27 |
+
|
28 |
+
# Animate the chart
|
29 |
+
if animation_button:
|
30 |
+
for i in range(10):
|
31 |
+
random_emotion = np.random.choice(emotions)
|
32 |
+
st.sidebar.radio("Choose an emotion", [random_emotion])
|
33 |
+
fig = px.sunburst(df, values="emoji", path=["emotion"], color="emoji")
|
34 |
+
st.plotly_chart(fig, use_container_width=True)
|