Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Needle plot in ggplot2 [duplicate]

Tags:

plot

r

ggplot2

I would like to have a needle plot like in

plot(1:10, 1:10, type = "h")

but in ggplot2. Is there a more or less direct way to do it? Or is that only possible with workarounds via line charts or something like that?

example needle plot

like image 915
Insa Avatar asked Dec 02 '25 21:12

Insa


1 Answers

library(ggplot2)
ggplot(data.frame(x=1:10, y=1:10),
       aes(x=x, ymax=y, ymin=0)) +
  geom_linerange()

resulting graph

like image 88
Roland Avatar answered Dec 04 '25 12:12

Roland



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!