R Data Visualization Recipes
上QQ阅读APP看书,第一时间看更新

Getting ready

Let's stick with a plot similar to the one displayed by Figure 2.11 (Recipe Adding regression lines, How to do it... section), calling only a few tweaks, like a different default theme and stroke and fill aesthetics. This plot will be stored by an object called core_plot and will work as our departure point for this recipe-it can be considered a good exploratory figure but not a publication one.

> library(ggplot2)
> core_plot <- ggplot( data = iris, aes(x = Petal.Length, y = Petal.Width,
> colour = Species, shape = Species, fill = Species)) +
> geom_point(alpha = .5, stroke = 1.5) +
> geom_smooth(method = 'lm', se = F, show.legend = F) +
> theme_minimal()
> core_plot

After running this code, following is the output we get:    

Figure 2.13 - the so called core_plot.

Now we have a few steps to go through.