ggplot2 in R
How to Label Outliers in Boxplots in ggplot2
This tutorial provides a step-by-step example of how to label outliers in boxplots in ggplot2.
Step 1: Create the Data Frame
First, let’s create the following...
ggplot2 in R
How to Add Caption to ggplot2 Plots (3 Examples)
You can use the following methods to add a caption to plots in ggplot2:
Method 1: Add Caption in Default Location
p +
labs(caption =...
ggplot2 in R
How to Change the Order of Facets in ggplot2 (With Example)
You can use the following basic syntax to specify the order of facets in ggplot2:
p +
facet_grid(~factor(my_variable, levels=c('val1', 'val2', 'val3', ...)))
The following example...
ggplot2 in R
How to Group by Two Columns in ggplot2 (With Example)
You can use the following basic syntax to group by two columns when creating a plot in ggplot2:
ggplot(df, aes(x=var1, y=var2, color=var3, shape=var4,
...
ggplot2 in R
How to Use hjust & vjust to Move Elements in ggplot2
You can use the hjust and vjust arguments to move elements horizontally and vertically, respectively, in ggplot2.
The following examples show how to use hjust...
ggplot2 in R
How to Change Number of Axis Ticks in ggplot2 (With Examples)
You can use the following basic syntax to change the number of axis ticks on plots in ggplot2:
p +
scale_x_continuous(n.breaks=10) +
scale_y_continuous(n.breaks=10)
The...
ggplot2 in R
How to Order Y-Axis Labels Alphabetically in ggplot2
You can use the following basic syntax to order the y-axis labels alphabetically in ggplot2:
#sort y-axis variable in alphabetical order
df$y_var#create scatter plot with y-axis...
Subscribe
- Never miss a story with notifications
- Gain full access to our premium content
- Browse free from up to 5 devices at once
Must read