[R-sig-Geo] line segments and stripcharts to plot range.

Dennis Murphy djmuser at gmail.com
Tue Oct 4 20:18:49 CEST 2011


Hi:

This is actually not too hard to do in ggplot2 using the linerange
geom. Using your data frame hummers (I love those little guys :),

library('ggplot2')
ggplot(hummers, aes(x = Eng)) +
    geom_linerange(aes(ymin = Min, ymax = Max), colour = 'red', size = 1.5) +
    labs(x = '', y = 'Elevation (ft)') +
    coord_flip()

HTH,
Dennis

On Tue, Oct 4, 2011 at 10:50 AM, Ben Weinstein
<benweinstein2010 at gmail.com> wrote:
> Hi all
>
> I have a simple plotting question. I have a dataframe, hummers, containing
> hummingbirds species and the max and min elevation for each species.  I'd
> like to plot a 1d chart, connecting the Min and Max elevation of each
> species, to create a line segment equal to the elevation range. the
> stripchart should contain 6 line segments, each labeled with the english
> name.
>
> hummers
>                         Eng                   Scientific
>  Min      Max
> 1     Band-tailed Barbthroat            Threnetes ruckeri          0
>  900
> 2     White-whiskered Hermit          Phaethornis yaruqui    1000   1500
> 3       Tawny-bellied Hermit    Phaethornis syrmatophorus 1300     2200
> 4    Green-fronted Lancebill          Doryfera ludoviciae        1100
>  1700
> 5   Wedge-billed Hummingbird           Schistes geoffroyi      800   2000
> 6       White-necked Jacobin          Florisuga mellivora         600  1200
>
>
> stripchart(x = list(Min, Max), vertical=F, method="jitter"
> group.names=c("Min","Max"))
> for(i in 1:nrow(hummers)){segments(rownames(hummers)[i], hummers$Max[i],
> rownames(hummers)[i], hummers$Min[i])}
>
> thank you for your help
>
> ben weinstein
>
>
>
>
> --
> Ben Weinstein
> Graduate Student
> Ecology and Evolution
> Stony Brook University
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



More information about the R-sig-Geo mailing list