knitr::opts_chunk$set(tidy=FALSE,warning=FALSE,message=FALSE,dev="svg",eval=capabilities("cairo")) Biocpkg <- function (pkg){ sprintf("[%s](http://bioconductor.org/packages/%s)", pkg, pkg) } CRANpkg <- function(pkg){ cran <- "https://CRAN.R-project.org/package" fmt <- "[%s](%s=%s)" sprintf(fmt, pkg, cran, pkg) }
library(ggplot2) library(ggstar)
ggstar
provides geoms for r CRANpkg("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.
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")
geom_star
is similar to geom_point
of r CRANpkg("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.
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
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
If you have questions/issues, please visit github issue tracker.
Here is the output of sessionInfo() on the system on which this document was compiled:
sessionInfo()
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.