Jul 09, 2026 — Digital Edition
George Ideas
Independent Journalism & Insight
Feature

How to Color Points in R

Coloring points in R, the programming language widely used for statistical computing and graphics, can significantly enhance the visual appeal and clarity of your plots. By default, R uses black points, but with a few simple commands, you can change the color of points to better suit your needs. Let's explore how to do this.

How to Color Lily Flower with Soft Shading and Stunning Floral Details | Bogiki
How to Color Lily Flower with Soft Shading and Stunning Floral Details | Bogiki

Before we dive into the specifics, ensure you have the ggplot2 package installed. If not, you can install it using the command install.packages("ggplot2"). Then, load the package with library(ggplot2).

an image of a diagram with different colors in the center and numbers on each side
an image of a diagram with different colors in the center and numbers on each side

Changing Point Color in ggplot2

ggplot2, a powerful plotting system in R, provides an easy way to change the color of points. You can do this using the color or colour (for consistency with ggplot2's British English roots) aesthetic mapping.

Cre: maisonnookcoloring
Cre: maisonnookcoloring

Here's a simple example. Let's create a scatter plot with blue points:

```R ggplot(mtcars, aes(x = mpg, y = hp)) + geom_point(color = "blue") ```

Using Named Colors

three different types of facial expressions on a whiteboard with text below them that reads red or pink, yellow or orange
three different types of facial expressions on a whiteboard with text below them that reads red or pink, yellow or orange

In the example above, we used the named color "blue". R supports a wide range of named colors, including "red", "green", "yellow", etc. You can find a list of named colors in R's help pages by typing colors().

Here's how you can use different named colors for different points based on a categorical variable:

```R ggplot(mpg, aes(x = displ, y = hwy, color = class)) + geom_point() ```

Using RGB or Hex Colors

a colorful parrot sitting on top of a tree branch next to a rainbow colored background
a colorful parrot sitting on top of a tree branch next to a rainbow colored background

If you want to use a specific color not available as a named color, you can use RGB or hex color codes. RGB values range from 0 to 255, while hex codes are six-digit numbers prefixed by a hash symbol (#).

Let's create a plot with points colored using RGB and hex codes:

```R ggplot(mpg, aes(x = displ, y = hwy)) + geom_point(color = rgb(0, 100, 0)) + geom_point(color = "#006400") ```

Changing Point Color in Base R

the color wheel with different shades to choose from, which one do not shade with?
the color wheel with different shades to choose from, which one do not shade with?

While ggplot2 is more powerful and flexible, you might still want to change the color of points in base R plots. You can do this using the col argument in plotting functions like points().

Here's how you can create a scatter plot with red points in base R:

a drawing of a green frog with red eyes
a drawing of a green frog with red eyes
how i color cloud in blue and white
how i color cloud in blue and white
Pointillist Artists, Pointillism Practice, Marker Pointillism, Art Activity For Elementary Students, Pointalism Ideas, Pointillism Art Easy, Stippling Worksheet, Pointillism Easy, Pointillism Worksheet
Pointillist Artists, Pointillism Practice, Marker Pointillism, Art Activity For Elementary Students, Pointalism Ideas, Pointillism Art Easy, Stippling Worksheet, Pointillism Easy, Pointillism Worksheet
an info sheet with different types of graphs and diagrams on it, including data points
an info sheet with different types of graphs and diagrams on it, including data points
Make Your Coloring Look Real 💧 Easy Droplet Trick
Make Your Coloring Look Real 💧 Easy Droplet Trick
the color wheel is shown with different colors
the color wheel is shown with different colors
a man making a funny face with his mouth wide open and the caption reads, three things i bet you didn't know about coloring your line art in procreate
a man making a funny face with his mouth wide open and the caption reads, three things i bet you didn't know about coloring your line art in procreate
Easy Coloring Tips: How to Create a Glow Effect. #art
Easy Coloring Tips: How to Create a Glow Effect. #art
how to make an origami water effect
how to make an origami water effect
Water Coloring Tutorial for Stress Relief and Mindful Coloring | Bogiki
Water Coloring Tutorial for Stress Relief and Mindful Coloring | Bogiki
Van Gogh Sunflower - Coloring Activity Worksheet
Van Gogh Sunflower - Coloring Activity Worksheet
How to color with pen tutorial🍓
How to color with pen tutorial🍓
patterns inspo
patterns inspo
How to do a TIKTOK Color Picking Trick in PROCREATE #Shorts
How to do a TIKTOK Color Picking Trick in PROCREATE #Shorts
Stippling Technique Shrub - Coloring Tutorial
Stippling Technique Shrub - Coloring Tutorial
COLOR INSIDE LINES
COLOR INSIDE LINES
How to Draw Plaid Pattern Step by Step for Adult Coloring Pages
How to Draw Plaid Pattern Step by Step for Adult Coloring Pages
Trendy Gradients in Web Design
Trendy Gradients in Web Design
a bunch of pencils that are sitting on top of a notepad with the caption how to blend w / colored pencils
a bunch of pencils that are sitting on top of a notepad with the caption how to blend w / colored pencils
how to blend w colored pencils 🎨💫
how to blend w colored pencils 🎨💫

```R plot(mpg$displ, mpg$hwy, col = "red", pch = 19) ```

Using Named Colors

Just like in ggplot2, you can use named colors in base R. Here's how you can use different named colors for different points based on a categorical variable:

```R with(mpg, plot(displ, hwy, col = as.numeric(class) + 1, pch = 19)) ```

Using RGB or Hex Colors

You can also use RGB or hex colors in base R. Here's how you can create a plot with points colored using RGB and hex codes:

```R with(mpg, plot(displ, hwy, col = rgb(0, 100, 0), pch = 19)) with(mpg, plot(displ, hwy, col = "#006400", pch = 19)) ```

Remember, the final color of your points will depend on the color space of your device or printer. Always check your plots on different devices to ensure they look as intended.

Now that you know how to color points in R, you can create more engaging and informative plots. Happy coding!