diff --git a/session_3/HTML_tuto_s3.Rmd b/session_3/HTML_tuto_s3.Rmd index e81f8cc44119e1f8f1670d6f76170cc0f5285008..c388fa91b8307e0f37606fe35a219dfcc19d285e 100644 --- a/session_3/HTML_tuto_s3.Rmd +++ b/session_3/HTML_tuto_s3.Rmd @@ -263,93 +263,36 @@ ggplot(data = diamonds, mapping = aes(x = cut, y = depth, color = clarity)) + ``` - -```{r diamonds_bar, cache = TRUE, fig.width=8, fig.height=4.5, message=FALSE} -bar <- ggplot(data = diamonds) + - geom_bar( - mapping = aes(x = cut, fill = cut), - show.legend = FALSE, - width = 1 - ) + - theme(aspect.ratio = 1) + - labs(x = NULL, y = NULL) -``` -**3_d** - - - -```{r diamonds_bar_plot, echo=F, cache = TRUE, fig.width=8, fig.height=4.5, message=FALSE} -bar +```{r dia_12, cache = TRUE, fig.width=8, fig.height=4.5, message=FALSE} +ggplot(data = diamonds, mapping = aes(x = depth, y = table)) + + geom_point() + + geom_abline() ``` -**3_d** - - -```{r diamonds_bar_flip, cache = TRUE, fig.width=8, fig.height=4.5, message=FALSE} -bar + coord_flip() -``` - - - -```{r mpg_jitter_noquickmap, cache = TRUE, fig.width=8, fig.height=4.5, message=FALSE} -ggplot(data = mpg) + - geom_jitter(mapping = aes(x = cty, y = hwy)) -``` - - -```{r mpg_jitter_quickmap, cache = TRUE, fig.width=3.5, fig.height=3.5, message=FALSE} -ggplot(data = mpg) + - geom_jitter(mapping = aes(x = cty, y = hwy)) + +```{r dia_quickmap, cache = TRUE, fig.width=8, fig.height=4.5, message=FALSE} +ggplot(data = diamonds, mapping = aes(x = depth, y = table)) + + geom_point() + + geom_abline() + coord_quickmap() ``` -```{r mpg_jitter_log, cache = TRUE, fig.width=8.5, fig.height=3.5, message=FALSE} -ggplot(data = mpg) + - geom_jitter(mapping = aes(x = cty, y = hwy)) + - scale_y_log10() + - scale_x_log10() -``` - -```{r diamonds_bar_polar, cache = TRUE, fig.width=5, fig.height=3.5, message=FALSE} -bar + coord_polar() -``` - -## Coordinate systems challenges - -- Turn a stacked bar chart into a pie chart using `coord_polar()`. -- What does `labs()` do? Read the documentation. -- What does the plot below tell you about the relationship between `city` and highway `mpg`? Why is `coord_fixed()` important? What does `geom_abline()` do? - -```{r mpg_point_fixed, eval = F, cache = TRUE, fig.width=4.5, fig.height=3.5, message=FALSE} -ggplot(data = mpg, mapping = aes(x = cty, y = hwy)) + - geom_point() + - geom_abline() + - coord_fixed() -``` - -## Coordinate systems challenges +```{r diamonds_bar, cache = TRUE, fig.width=8, fig.height=4.5, message=FALSE} +bar <- ggplot(data = diamonds, mapping = aes(x = cut, fill = cut)) + + geom_bar( show.legend = FALSE, width = 1 ) + + theme(aspect.ratio = 1) + + labs(x = NULL, y = NULL) -```{r diamonds_barplot_pos_fill_polar, cache = TRUE, fig.width=8, fig.height=4.5, message=FALSE} -ggplot(data = diamonds) + - geom_bar(mapping = aes(x = cut, fill = clarity), - position = "fill") + - coord_polar() +bar ``` -## Coordinate systems challenges -```{r mpg_point_nofixed_plot, eval = T, cache = TRUE, fig.width=8, fig.height=3.5, message=FALSE} -ggplot(data = mpg, mapping = aes(x = cty, y = hwy)) + - geom_point() + geom_abline() +```{r diamonds_bar_polar, cache = TRUE, fig.width=8, fig.height=4.5, message=FALSE} +bar + coord_polar() ``` -## Coordinate systems challenges -```{r mpg_point_fixed_plot, eval = T, cache = TRUE, fig.width=8, fig.height=3.5, message=FALSE} -ggplot(data = mpg, mapping = aes(x = cty, y = hwy)) + - geom_point() + geom_abline() + coord_fixed() -``` +##See you to Session#4 : "" \ No newline at end of file