|
import random |
|
import streamlit as st |
|
import plotly.express as px |
|
|
|
|
|
st.set_page_config(page_title="Dice-Roll-Treemap-Plotly - d100 Dice Roll Treemap Chart") |
|
|
|
|
|
def roll_dice(): |
|
return random.randint(1, 100) |
|
|
|
|
|
rolls = [roll_dice() for _ in range(1000)] |
|
|
|
|
|
counts = {} |
|
for roll in rolls: |
|
if roll not in counts: |
|
counts[roll] = 1 |
|
else: |
|
counts[roll] += 1 |
|
|
|
|
|
fig = px.treemap( |
|
names=[f":game_die: {roll}" for roll in counts.keys()], |
|
parents=["Dice Rolls" for _ in counts.keys()], |
|
values=list(counts.values()), |
|
color=list(counts.keys()), |
|
color_continuous_scale="YlOrRd", |
|
title="d100 Dice Roll Treemap Chart", |
|
) |
|
|
|
|
|
st.plotly_chart(fig) |
|
|