Skip to content

Commit e8e0b3f

Browse files
waffle chart done
1 parent 496f621 commit e8e0b3f

File tree

1 file changed

+6
-19
lines changed
  • 3-Data-Visualization/R/11-visualization-proportions

1 file changed

+6
-19
lines changed

3-Data-Visualization/R/11-visualization-proportions/README.md

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -150,25 +150,12 @@ View(cap_color)
150150

151151
Create a waffle chart by creating labels and then grouping your data:
152152

153-
```python
154-
import pandas as pd
155-
import matplotlib.pyplot as plt
156-
from pywaffle import Waffle
157-
158-
data ={'color': ['brown', 'buff', 'cinnamon', 'green', 'pink', 'purple', 'red', 'white', 'yellow'],
159-
'amount': capcolor['class']
160-
}
161-
162-
df = pd.DataFrame(data)
163-
164-
fig = plt.figure(
165-
FigureClass = Waffle,
166-
rows = 100,
167-
values = df.amount,
168-
labels = list(df.color),
169-
figsize = (30,30),
170-
colors=["brown", "tan", "maroon", "green", "pink", "purple", "red", "whitesmoke", "yellow"],
171-
)
153+
```r
154+
library(waffle)
155+
names(cap_color$count) = paste0(cap_color$cap.color)
156+
waffle((cap_color$count/10), rows = 7, title = "Waffle Chart")+scale_fill_manual(values=c("brown", "#F0DC82", "#D2691E", "green",
157+
"pink", "purple", "red", "grey",
158+
"yellow","white"))
172159
```
173160

174161
Using a waffle chart, you can plainly see the proportions of cap colors of this mushrooms dataset. Interestingly, there are many green-capped mushrooms!

0 commit comments

Comments
 (0)