Blog

We provide practical tutorials on data mining, visualization and statistics for decision making.

In this article, you will learn how to change a ggplot legend order. Prerequisites Load the ggplot2 package and set the theme function theme_classic() as the default theme: library(ggplot2) theme_set( theme_classic() ) Basic plots p <- ggplot(iris, aes(x = Species, y = Sepal.Length)) +...

How to Change GGPlot Legend Order

In this article, you will learn how to change a ggplot legend order. Prerequisites Load the ggplot2 package and set the theme function theme_classic() as the default theme: library(ggplot2) theme_set( theme_classic() ) Basic plots p <- ggplot(iris, aes(x = Species, y = Sepal.Length)) +...

  In this article, you will learn how to set ggplot breaks for continuous x and y axes. The function scale_x_continuous() and scale_y_continuous() can be used for ggplot axis breaks settings. Prerequisites Load the ggplot2 package and set the theme function theme_classic() as the...

How to Set GGPlot Breaks

  In this article, you will learn how to set ggplot breaks for continuous x and y axes. The function scale_x_continuous() and scale_y_continuous() can be used for ggplot axis breaks settings. Prerequisites Load the ggplot2 package and set the theme function theme_classic() as the...

In this article, you will learn how to easily create a histogram by group in R using the ggplot2 package. Prerequisites Load the ggplot2 package and set the theme function theme_classic() as the default theme: library(ggplot2) theme_set( theme_classic() + theme(legend.position = "top") ) Create...

How to Create Histogram by Group in R

In this article, you will learn how to easily create a histogram by group in R using the ggplot2 package. Prerequisites Load the ggplot2 package and set the theme function theme_classic() as the default theme: library(ggplot2) theme_set( theme_classic() + theme(legend.position = "top") ) Create...

You will learn how to plot smooth line using ggplot2. Contents: Prerequisites Key R function: geom_smooth() Regression line Loess method for local regression fitting Polynomial interpolation Spline interpolation Prerequisites Load the ggplot2 package and set the default theme to theme_minimal(): library(ggplot2) theme_set( theme_bw() +...

How to Plot a Smooth Line using GGPlot2

You will learn how to plot smooth line using ggplot2. Contents: Prerequisites Key R function: geom_smooth() Regression line Loess method for local regression fitting Polynomial interpolation Spline interpolation Prerequisites Load the ggplot2 package and set the default theme to theme_minimal(): library(ggplot2) theme_set( theme_bw() +...

There are many R packages/functions for combining multiple ggplots into the same graphics. These include: gridExtra::grid.arrange() and cowplot::plot_grid. Recently, Thomas Lin Pederson developed the patchwork R package to make very easy the creation of ggplot multiple plots In this article, you will learn how...

GGPlot Multiple Plots Made Ridiculuous Simple Using Patchwork R Package

There are many R packages/functions for combining multiple ggplots into the same graphics. These include: gridExtra::grid.arrange() and cowplot::plot_grid. Recently, Thomas Lin Pederson developed the patchwork R package to make very easy the creation of ggplot multiple plots In this article, you will learn how...

This article provide many examples for creating a ggplot map. You will also learn how to create a choropleth map, in which areas are patterned in proportion to a given variable values being displayed on the map, such as population life expectancy or density....

How to Create a Map using GGPlot2

This article provide many examples for creating a ggplot map. You will also learn how to create a choropleth map, in which areas are patterned in proportion to a given variable values being displayed on the map, such as population life expectancy or density....

  This article describes how to change easily ggplot facet labels. Contents: Prerequisites Basic ggplot with facet Change the text of facet labels Customize facet labels appearance Change facet background color Prerequisites Load required packages and set the theme function theme_light() as the...

How to Change GGPlot Facet Labels

  This article describes how to change easily ggplot facet labels. Contents: Prerequisites Basic ggplot with facet Change the text of facet labels Customize facet labels appearance Change facet background color Prerequisites Load required packages and set the theme function theme_light() as the...

This article describes how to install ggplot2 in R. Installing ggplot2 The ggplot2 package can be easily installed using the R function install.packages(). You need to type the following R code in the console: install.packages("ggplot2") The above code will automatically download the ggplot2 package,...

How to Install GGPLOT2 in R

This article describes how to install ggplot2 in R. Installing ggplot2 The ggplot2 package can be easily installed using the R function install.packages(). You need to type the following R code in the console: install.packages("ggplot2") The above code will automatically download the ggplot2 package,...

This article describes how to remove legend from a plot created using the ggplot2 package. You will learn how to: Hide the entire legend to create a ggplot with no legend. Remove the legend for a specific aesthetic. Prerequisites Load required packages and set...

How to Remove Legend from a GGPlot

This article describes how to remove legend from a plot created using the ggplot2 package. You will learn how to: Hide the entire legend to create a ggplot with no legend. Remove the legend for a specific aesthetic. Prerequisites Load required packages and set...

This article describes how to change ggplot legend size. You will learn how to modify the legend title and text size. Prerequisites Load required packages and set the theme function theme_minimal() as the default theme: library(ggplot2) theme_set(theme_minimal()) Basic plot Start by creating a box...

How to Change GGPlot Legend Size

This article describes how to change ggplot legend size. You will learn how to modify the legend title and text size. Prerequisites Load required packages and set the theme function theme_minimal() as the default theme: library(ggplot2) theme_set(theme_minimal()) Basic plot Start by creating a box...