File size: 1,880 Bytes
5632d5e
2d9989f
 
 
fa9fdb8
2d9989f
 
8f779b2
2d9989f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e83e13a
2d9989f
 
 
 
 
 
 
5632d5e
2d9989f
e83e13a
2d9989f
 
 
 
 
 
e83e13a
 
 
 
 
 
 
 
 
 
 
 
288a538
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import streamlit as st
import plotly.graph_objects as go
import pandas as pd
import plotly.express as px
from plotly.subplots import make_subplots

#Read Avocado Dataset
data = pd.read_csv("src/avocado.csv")

st.header("Pie Chart")
# Implementing Pie Plot
pie_chart = go.Figure(
go.Pie(labels = data.type,
values = data.AveragePrice,
hoverinfo = "label+percent",
textinfo = "value+percent"
))

st.plotly_chart(pie_chart)

st.header("Donut Chart")
# Donut Chart
donut_chart = px.pie(
names = data.type,
values = data.AveragePrice,
hole=0.25,
)

st.plotly_chart(donut_chart)

st.header("Scatter Chart")
#Scatter
scat = px.scatter(
x = data.Date,
y = data.AveragePrice
)
st.plotly_chart(scat)


# Minimizing Dataset
albany_df = data[data['region']=="Albany"]
al_df = albany_df[albany_df["year"]==2015]
#Line
line_chart = px.line(
x = al_df["Date"],
y = al_df["Large Bags"]
)

line_chart.update_traces(line_color = "orange")
st.header("Line Chart")
st.plotly_chart(line_chart)

# Bar graph
st.header("Bar Graph")
bar_graph = px.bar(
al_df,
title = "Bar Graph",
x = "Date",
y = "Large Bags"
)
st.plotly_chart(bar_graph)

#Bar Color
st.header("Bar Graph with Color")
bar_graph = px.bar(
x = al_df["Date"],
y = al_df["Large Bags"],
title = "Bar Graph",
color=al_df["Large Bags"]
)
st.plotly_chart(bar_graph)

# Horizontal Bar Graph
st.header("Horizontal Bar Graph")
bar_graph = px.bar(
al_df,
x = "Large Bags",
y = "Date",
title = "Bar Graph",
color="Large Bags",
orientation='h'
)
st.plotly_chart(bar_graph)


st.header("Subplots")
fig = make_subplots(rows=3, cols=1)
# First Subplot
fig.add_trace(go.Scatter(
x=al_df["Date"],
y=al_df["Total Bags"],
), row=1, col=1)
# Second SubPlot
fig.add_trace(go.Scatter(
x=al_df["Date"],
y=al_df["Small Bags"],
), row=2, col=1)
# Third SubPlot
fig.add_trace(go.Scatter(
x=al_df["Date"],
y=al_df["Large Bags"],
), row=3, col=1)
st.plotly_chart(fig)