Giter Site home page Giter Site logo

shixiangwang / polar Goto Github PK

View Code? Open in Web Editor NEW
9.0 1.0 0.0 1.11 MB

polar: Dots and Their Connections in Polar Coordinate System

Home Page: https://shixiangwang.github.io/polar/

License: GNU General Public License v3.0

R 100.00%
ggplot2-enhancements

polar's Introduction

ggpolar: Dots and Their Connections in Polar Coordinate System

ggpolar status badge CRAN status

{ggpolar} provides a very flexible way to create dots in coordinate system for event list and connect the dots with segments based on {ggplot2}.

Installation

You can install the released version of {ggpolar} from CRAN with:

install.packages("ggpolar")

You can install the development version of {ggpolar} from GitHub with:

remotes::install_github("ShixiangWang/polar")

Example

Init a polar plot

library(ggpolar)
#> Loading required package: ggplot2

data <- data.frame(x = LETTERS[1:7])

p1 <- polar_init(data, x = x)
p1

# Set aes value
p2 <- polar_init(data, x = x, size = 3, color = "red", alpha = 0.5)
p2

# Set aes mapping
set.seed(123L)
data1 <- data.frame(
  x = LETTERS[1:7],
  shape = c("r", "r", "r", "b", "b", "b", "b"),
  color = c("r", "r", "r", "b", "b", "b", "b"),
  size = abs(rnorm(7))
)
# Check https://ggplot2.tidyverse.org/reference/geom_point.html
# for how to use both stroke and color
p3 <- polar_init(data1, x = x, aes(size = size, color = color, shape = shape), alpha = 0.5)
p3

Connect polar dots

data2 <- data.frame(
  x1 = LETTERS[1:7],
  x2 = c("B", "C", "D", "E", "C", "A", "C"),
  color = c("r", "r", "r", "b", "b", "b", "b")
)
p4 <- p3 + polar_connect(data2, x1, x2)
p4

# Unlike polar_init, mappings don't need to be included in aes()
p5 <- p3 + polar_connect(data2, x1, x2, color = color, alpha = 0.8, linetype = 2)
p5

# Use two different color scales
if (requireNamespace("ggnewscale")) {
  library(ggnewscale)
  p6 = p3 +
    new_scale("color") +
    polar_connect(data2, x1, x2, color = color, alpha = 0.8, linetype = 2)
  print(p6 + scale_color_brewer())
  print(p6 + scale_color_manual(values = c("darkgreen", "magenta")))
}
#> Loading required namespace: ggnewscale
#> Warning: package 'ggnewscale' was built under R version 4.2.1

Citation

If you use {ggpolar} in academic research, please cite the following paper along with the GitHub repo.

Antigen presentation and tumor immunogenicity in cancer immunotherapy response prediction, eLife. https://doi.org/10.7554/eLife.49020.

polar's People

Contributors

shixiangwang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

polar's Issues

support curved line?

Thank you for this great package. Can make connect line curved? Thank you for your reply!

Issues with next version of ggplot2

Hi

We preparing the next release of ggplot2 and our reverse dependency checks show that your package is failing with the new version. Looking into it we see that the issues are due to our switch to using the linewidth aesthetic for stroke width instead of size. Please see https://www.tidyverse.org/blog/2022/08/ggplot2-3-4-0-size-to-linewidth/ for more info on this.

Be aware that there is an additional issue with a warning about '::' or ':::' import not declared from: β€˜cli’ which is likely caused by ggpolar including code from ggplot2 at build time. See https://www.tidyverse.org/blog/2022/09/playing-on-the-same-team-as-your-dependecy/ for more info on this.

You can install the release candidate of ggplot2 using devtools::install_github('tidyverse/[email protected]') to test this out.

We plan to submit ggplot2 by the end of October and hope you can have a fix ready before then

Kind regards
Thomas

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.