-
Notifications
You must be signed in to change notification settings - Fork 0
/
statsplots.py
37 lines (29 loc) · 1.58 KB
/
statsplots.py
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
26
27
28
29
30
31
32
33
34
35
36
37
import streamlit as st
import plotly.express as px
import pandas as pd
def draw_plots(df: pd.DataFrame):
if df.empty:
st.warning('No data available')
return
st.dataframe(df)
bins = pd.cut(df['Lines of Code'], bins=3)
df['Category'] = [f'{int(interval.left)}-{int(interval.right)}' for interval in bins]
fig0 = px.parallel_categories(df, color='Lines of Code', dimensions=['Category', 'Repo'],
color_continuous_scale=px.colors.sequential.Inferno,
title='Lines of Code per Category (Categories)')
st.plotly_chart(fig0, use_container_width=True)
fig1 = px.histogram(df, x='Repo', y='Lines of Code', barmode='group', text_auto=True,
title='Lines of Code per Repository')
fig1.update_traces(textangle=0, textposition="outside", cliponaxis=False)
st.plotly_chart(fig1, use_container_width=True)
fig2 = px.scatter(df, x='Repo', y='Lines of Code', title='Lines of Code per Repository (Scatter Plot)',
hover_data={'Repo': False, 'File': True})
st.plotly_chart(fig2, use_container_width=True)
cols = st.columns(2)
with cols[0]:
fig3 = px.histogram(df, x='Lines of Code', marginal='rug', title='Lines of Code Distribution (Histogram)')
st.plotly_chart(fig3, use_container_width=True)
with cols[1]:
fig4 = px.pie(df, names='Repo', values='Lines of Code', title='Lines of Code per Repository (Pie Chart)')
fig4.update_traces(textposition='inside')
st.plotly_chart(fig4, use_container_width=True)