1

After experimenting with different point sizes and shapes when plotting with ggplot2, I found that I was no longer able to plot circular points. These simple examples illustrate the problem:

# Plot 1 - square points (symbol #15) appear correctly
#
df = data.frame(x = c(1, 2, 3), y = c(4, 5, 6))
g1 <- ggplot(df, aes(x = x, y = y))
g1 <- g1 + geom_point(size = 3, shape = 15)
g1

Plot 1 output:

enter image description here

# Plot 2 - circular points (symbol #16) appear as diamonds
#
df = data.frame(x = c(1, 2, 3), y = c(4, 5, 6))
g1 <- ggplot(df, aes(x = x, y = y))
g1 <- g1 + geom_point(size = 3, shape = 16)
g1

Plot 2 output:

enter image description here

# Plot 3 - triangular points (symbol #17) appear correctly
#
df = data.frame(x = c(1, 2, 3), y = c(4, 5, 6))
g1 <- ggplot(df, aes(x = x, y = y))
g1 <- g1 + geom_point(size = 3, shape = 17)
g1

Plot 3 output:

enter image description here

# Plot 4 - diamond points (symbol #18) appear correctly
#
df = data.frame(x = c(1, 2, 3), y = c(4, 5, 6))
g1 <- ggplot(df, aes(x = x, y = y))
g1 <- g1 + geom_point(size = 3, shape = 18)
g1

Plot 4 output:

enter image description here

What do I have to do to plot circular points again? (I'm running R 3.1.3 and RStudio 0.98.1103 in Windows 7.)

3
  • How are you saving the plots? Commented Jul 31, 2015 at 19:56
  • I'm not saving them yet, just copying them from the Plots pane in RStudio. Commented Jul 31, 2015 at 20:09
  • 1
    Try looking at them after using ggsave(g1, filename = "image.png"). Commented Jul 31, 2015 at 20:12

1 Answer 1

3

It looks like it has to do with the limited resolution of the RStudioGD() graphics device. It becomes a non-issue by avoiding the RStudio interface:

g1 <- ggplot(df, aes(x = x, y = y))
g1 <- g1 + geom_point(size = 3)
g1

(from RStudio interface via save image)

enter image description here

ggsave(g1, filename = "image.png")

enter image description here

ggsave gives you more finely-tuned control over graphics parameters, including the height/width, dpi (for raster images, eg. png), and file format. See the ?ggsave documentation for details.

Or alternatively, bump the geom_point up to size = 4.

Sign up to request clarification or add additional context in comments.

1 Comment

That was it-- the graph is correct when saved as a file. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.