ds %>%
ggplot(aes(wind_dir_3pm, fill=wind_dir_3pm)) +
geom_bar() +
scale_y_continuous(labels=comma) +
labs(x=vnames["wind_dir_3pm"], y="Count") +
theme(legend.position="none")
Colour can add interest to a plot, though it is usually good to use
the colour to communicate further information about the data. In this
example we add a spread of colour across the bars by specifying the
aesthetic fill=wind_dir_3pm . Thus the colour used is
controlled by the values of the variable
wind_dir_3pm. This is also the variable being plotted on
the x-axis and so as an example it adds no new information to the
plot. A good set of colours is chosen by default and could be changed
through themes.
We add a ggplot2::theme() element here to remove the legend
that would be displayed by default, by indicating that the
legend.position="none" . An alternative to turn the
legend off is to provide show.legend=FALSE to the
layer (i.e., ggplot2::geom_bar()). This then allows layer
specific control of the legends.
|