From d358378d90f24c8a291acf21c5d86e83f0a7cab9 Mon Sep 17 00:00:00 2001 From: Chris Lo Date: Tue, 10 Sep 2024 13:25:41 -0700 Subject: [PATCH] Update 05-data-visualization.Rmd --- 05-data-visualization.Rmd | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/05-data-visualization.Rmd b/05-data-visualization.Rmd index f2726b7..7b0c6f1 100644 --- a/05-data-visualization.Rmd +++ b/05-data-visualization.Rmd @@ -189,3 +189,30 @@ hist(iris$Sepal.Length) ```{r, out.width="200%"} hist(iris$Sepal.Length) ``` + +matplotlib + +```{python} +import matplotlib.pyplot as plt + +fig, ax = plt.subplots() + +fruits = ['apple', 'blueberry', 'cherry', 'orange'] +counts = [40, 100, 30, 55] +bar_labels = ['red', 'blue', '_red', 'orange'] +bar_colors = ['tab:red', 'tab:blue', 'tab:red', 'tab:orange'] + +ax.bar(fruits, counts, label=bar_labels, color=bar_colors) + +ax.set_ylabel('fruit supply') +ax.set_title('Fruit supply by kind and color') +ax.legend(title='Fruit color') + + +``` + +now show + +```{python} +plt.show() +```