A table is printed out with some great data for analysis:
@ -32,55 +30,60 @@ A table is printed out with some great data for analysis:
| Poisonous | Convex | Smooth | Brown | Bruises | Pungent | Free | Close | Narrow | Black | Enlarging | Equal | Smooth | Smooth | White | White | Partial | White | One | Pendant | Black | Scattered | Urban |
| Edible | Convex | Smooth | Yellow | Bruises | Almond | Free | Close | Broad | Black | Enlarging | Club | Smooth | Smooth | White | White | Partial | White | One | Pendant | Brown | Numerous | Grasses |
| Edible | Bell | Smooth | White | Bruises | Anise | Free | Close | Broad | Brown | Enlarging | Club | Smooth | Smooth | White | White | Partial | White | One | Pendant | Brown | Numerous | Meadows |
| Poisonous | Convex | Scaly | White | Bruises | Pungent | Free | Close | Narrow | Brown | Enlarging | Equal | Smooth | Smooth | White | White | Partial | White | One | Pendant | Black | Scattered | Urban |
| Poisonous | Convex | Scaly | White | Bruises | Pungent | Free | Close | Narrow | Brown | Enlarging | Equal | Smooth | Smooth | White | White | Partial | White | One | Pendant | Black | Scattered | Urban
| Edible | Convex |Smooth | Green | No Bruises| None |Free | Crowded | Broad | Black | Tapering | Equal | Smooth | Smooth | White | White | Partial | White | One | Evanescent | Brown | Abundant | Grasses
|Edible | Convex | Scaly | Yellow | Bruises | Almond | Free | Close | Broad | Brown | Enlarging | Club | Smooth | Smooth | White | White | Partial | White | One | Pendant | Black | Numerous | Grasses
Right away, you notice that all the data is textual. You will have to convert this data to be able to use it in a chart. Most of the data, in fact, is represented as an object:
Voila, a pie chart showing the proportions of this data according to these two classes of mushrooms. It's quite important to get the order of the labels correct, especially here, so be sure to verify the order with which the label array is built!
@ -92,26 +95,29 @@ A somewhat more visually interesting pie chart is a donut chart, which is a pie
Take a look at the various habitats where mushrooms grow:
```python
habitat=mushrooms.groupby(['habitat']).count()
habitat
```r
habitat=mushrooms %>%
group_by(habitat) %>%
summarise(count=n())
View(habitat)
```
Here, you are grouping your data by habitat. There are 7 listed, so use those as labels for your donut chart:
Here, you are grouping your data by habitat. There are 7 listed, so use those as labels for your donut chart:
plt.show()
```r
library(webr)
PieDonut(habitat, aes(habitat, count=count))
```

@ -123,10 +129,10 @@ Donut charts can be tweaked in several ways to change the labels. The labels in
Now that you know how to group your data and then display it as a pie or donut, you can explore other types of charts. Try a waffle chart, which is just a different way of exploring quantity.
## Waffles!
A 'waffle' type chart is a different way to visualize quantities as a 2D array of squares. Try visualizing the different quantities of mushroom cap colors in this dataset. To do this, you need to install a helper library called [PyWaffle](https://pypi.org/project/pywaffle/) and use Matplotlib:
A 'waffle' type chart is a different way to visualize quantities as a 2D array of squares. Try visualizing the different quantities of mushroom cap colors in this dataset. To do this, you need to install a helper library called [waffle](https://r-charts.com/part-whole/waffle-chart-ggplot2/) and use it to generate your visualization:
Create a basic scatterplot to show the relationship between the price per pound of honey and its U.S. state of origin. Make the `y` axis tall enough to display all the states: