1. Introduction

ggstar provides geoms for ggplot2 to create more easily discernible shapes:

geom_star

p1 <- show_starshapes()
p1

And the default is: c(1, 13, 15, 11, 12, 14, 29, 2, 27)[seq_len(n)]. n is the number of shapes you want to use.

2. Install

ggstar has been submitted on CRAN, you can use the following to install it.

# Release
install.packages("ggstar")

# Or for devel
if(!requireNamespace("remotes", quietly=TRUE)){
    install.packages("remotes")
}
remotes::install_github("xiangpin/ggstar")

3. Usage

geom_star is similar to geom_point of ggplot2. The difference point is geom_star use starshape to mapping the starshapes. The another is geom_star use scale_starshape_manual for manual scale. And the shapes will be not distorted on cartesian coordinates or polar coordinates.

3.1 Cartesian coordinates

library(ggplot2)
library(ggstar)
p2 <- ggplot(data=iris, aes(x=Sepal.Width,y=Sepal.Length)) + 
      geom_star(aes(starshape=Species, fill=Species), size=2.5) +
      scale_fill_manual(values=c("#E41A1C", "#377EB8", "#4DAF4A")) +
      theme(legend.spacing.y = unit(0.02, "cm"))
p2

3.2 Polar coordinates

p3 <- ggplot(data=mtcars, aes(x=wt, y=mpg)) +
      geom_star(aes(fill=cyl), size=2.5) +
      scale_fill_gradient(low="blue", high="red") +
      coord_polar() +
      theme(panel.border=element_blank(),
            legend.spacing.y = unit(0.02, "cm"))
p3

4. Need helps?

If you have questions/issues, please visit github issue tracker.

5. Session information

Here is the output of sessionInfo() on the system on which this document was compiled:

## R version 4.2.2 (2022-10-31)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 18.04.4 LTS
## 
## Matrix products: default
## BLAS:   /mnt/d/UbuntuApps/R/4.2.2/lib/R/lib/libRblas.so
## LAPACK: /mnt/d/UbuntuApps/R/4.2.2/lib/R/lib/libRlapack.so
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] ggstar_1.0.4  ggplot2_3.4.0
## 
## loaded via a namespace (and not attached):
##  [1] highr_0.9        bslib_0.4.1      compiler_4.2.2   pillar_1.8.1    
##  [5] jquerylib_0.1.4  prettydoc_0.4.1  tools_4.2.2      digest_0.6.30   
##  [9] jsonlite_1.8.3   evaluate_0.18    lifecycle_1.0.3  tibble_3.1.8    
## [13] gtable_0.3.1     pkgconfig_2.0.3  rlang_1.0.6      cli_3.4.1       
## [17] yaml_2.3.6       xfun_0.34        fastmap_1.1.0    gridExtra_2.3   
## [21] withr_2.5.0      stringr_1.4.1    dplyr_1.0.10     knitr_1.40      
## [25] generics_0.1.3   sass_0.4.2       vctrs_0.5.0      grid_4.2.2      
## [29] tidyselect_1.2.0 glue_1.6.2       R6_2.5.1         fansi_1.0.3     
## [33] rmarkdown_2.17   farver_2.1.1     magrittr_2.0.3   scales_1.2.1    
## [37] htmltools_0.5.3  colorspace_2.0-3 labeling_0.4.2   utf8_1.2.2      
## [41] stringi_1.7.8    munsell_0.5.0    cachem_1.0.6