[英]Drawing a triangle with geom_polygon
Hi there I need some help drawing a simple triangle 嗨,我需要一些帮助绘制一个简单的三角形
library(ggplot2)
library(data.table)
dt.triangle <- data.table(group = c(1,1,1), polygon.x = c(2,4,4), polygon.y = c(1,1,3))
p <- ggplot()
p <- p + geom_polygon(
data = dt.triangle
,aes(
x=polygon.x
,y=polygon.y
,group=group
)
)
p
I'm not that satisfied with the drawing/rendering of the hypotneuse, somehow I want to draw a line that doesn't show this "saw teeth". 我对hypotneuse的绘制/渲染并不满意,不知怎的,我想绘制一条不显示这种“锯齿”的线。
Do I miss something? 我错过了什么吗?
For some reason I want to use ggplot2 in combination with geom_polygon. 出于某种原因,我想将ggplot2与geom_polygon结合使用。
Any help is appreciated 任何帮助表示赞赏
Tom 汤姆
The effect is because the default rendering engine doesn't use anti-aliasing. 效果是因为默认渲染引擎不使用消除锯齿。 If you save as a pdf or svg it will render more smoothly. 如果您保存为pdf或svg,它将呈现更流畅。
Alternatively, you can use a Cairo
device: 或者,您可以使用Cairo
设备:
library(Cairo)
CairoWin() # or perhaps CairoX11()
p
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.