【发布时间】:2015-07-31 19:52:12
【问题描述】:
在使用 ggplot2 绘图时尝试了不同的点大小和形状后,我发现我不再能够绘制圆形点。这些简单的例子说明了这个问题:
# 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
绘图 1 输出:
# 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
绘图 2 输出:
# 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
绘图 3 输出:
# 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
绘图 4 输出:
我该怎么做才能再次绘制圆形点? (我在 Windows 7 中运行 R 3.1.3 和 RStudio 0.98.1103。)
【问题讨论】:
-
你是如何保存地块的?
-
我还没有保存它们,只是从 RStudio 的 Plots 窗格中复制它们。
-
在使用
ggsave(g1, filename = "image.png")后尝试查看它们。
标签: r ggplot2 rstudio shape point