Drawing a triangle using geom_polygon

Hi, I need help creating 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 am not happy with the hypotneuse drawing / rendering, anyway I want to draw a line that does not show these β€œsaw teeth”.

Did I miss something?

For some reason, I want to use ggplot2 in combination with geom_polygon.

Any help is appreciated

Tom

+4
source share
1 answer

The effect is caused by the fact that the default rendering engine does not use anti-aliasing. If you save the file in pdf or svg format, it will look more smoothly.

Alternatively, you can use the Cairo device:

 library(Cairo) CairoWin() # or perhaps CairoX11() p 
+2
source

Source: https://habr.com/ru/post/1482409/


All Articles