Let’s start with a very basic
ggplot2 scatterplot. The axis usually looks very good with default option as you can see here.
Basically two main functions will allow to customize it:
theme()to change the axis appearance
scale_y_to change the axis type
Let’s see how to use them
Two basic options that are used in almost every charts are
xlim() to control the axis title and the axis limits respectively.
Note : it is possible to specify only the lower or upper bound of a limit. For instance, try
theme() function allows to customize all parts of the
ggplot2 chart. The
axis.title. controls the axis title appearance. Since it is text, features are wrapped in a
element_text() function. The code below shows how to change the most common features:
Using pretty much the same process, the
axis.text() function allows to control text label features. Once more, using
axis.text.x() would modify the x axis only.
axis.ticks() function controls the ticks appearance.
axis.line() controles the axis line. Both of them are lines, so options are wrapped in a
linetype controls the type of line in use, see the ggplot2 section for more.