Ask Your Question
1

How to prevent tearing while creating polygons with holes in ggplot2?

asked 2023-07-12 14:59:11 +0000

scrum gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2023-07-12 15:08:01 +0000

nofretete gravatar image

There are a few ways to prevent tearing while creating polygons with holes in ggplot2:

  1. Use the fortify() function to convert the data frame for your polygon(s) into a format that ggplot2 understands. This can help to prevent overlapping or missing edges.

  2. Use the geom_polygon() function to create the polygons and set the fill color to NA. This will create the outlines of the polygons without filling them in.

  3. Use the ggforce package to create polygons with holes. This package includes the geom_polygonh() function which allows you to specify the coordinates for both the outer and inner polygons.

  4. Use the sf package to create polygons with holes. This package includes the st_polygon() function which allows you to specify the coordinates for both the outer and inner polygons.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-07-12 14:59:11 +0000

Seen: 21 times

Last updated: Jul 12 '23