Intro to Visualization with R
Manual Aesthetics

We’ve reviewed how to assign data-driven aesthetic mappings at the canvas level and at the geom level. However, sometimes you’ll want to change an aesthetic based on visual preference and not data. You might think of this as “manually” changing an aesthetic.

If you have a pre-determined value in mind, you provide a named aesthetic parameter and the value for that property without wrapping it in an aes(). For example, if you wanted to make all the points on the scatter plot layer dark red because that’s in line with the branding of the visualization you are preparing, you could simply pass in a color parameter with a manual value darkred or any color value like so:

viz <- ggplot(data=airquality, aes(x=Ozone, y=Temp)) + geom_point(color="darkred")
  • Note that we did not wrap the color argument inside aes() because we are manually setting that aesthetic. Here are more aesthetics for the geom_point() layer: x, y, alpha, color, fill, group, shape, size, stroke. The alpha aesthetic describes opacity of the points, and the shape of the dots could be different than a dot. Read more about the values each of these aesthetics take in the geom_point() layer documentation.

The code above would render the following plot: Dark scatterplot layer We advise that your aesthetic choices have intention behind them. Too much styling can overcomplicate the appearance of a plot, making it difficult to read.



There seems to be some crowding in our movie scatterplot. Let’s change the opacity of our points by making them .5 translucent. We can accomplish by manually assigning the alpha value of the geom_point() layer.

Folder Icon

Take this course for free

Already have an account?