Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do you add a line segment to a stripchart in R?

This is likely a very easy question, but I’m not great with R and haven’t found a simple answer elsewhere on the internet.

I want to add a line segment connecting the two points in this stripchart, but cannot figure out how to do so.

stripchart(c(0.5, 1.5), pch = "+")

Any help would be much appreciated!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Create a data frame or vectors with the coordinates for the line and plot with lines

df1 <- data.frame(x = c(0.5, 1.5),
                  y = 1)

stripchart(c(0.5, 1.5), pch = "+")
lines(df1$x, df1$y)

Created on 2021-12-18 by the reprex package (v2.0.1)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading