<!-- Generated by pkgdown: do not edit by hand -->
<!DOCTYPE html>
<html lang="en">
  <head>
  <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Init a dot plot in polar system — polar_init • ggpolar</title>


<!-- jquery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<!-- Bootstrap -->

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha256-bZLfwXAP04zRMK2BjiO8iu9pf4FbLqX6zitd+tIvLhE=" crossorigin="anonymous" />

<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script>

<!-- bootstrap-toc -->
<link rel="stylesheet" href="../bootstrap-toc.css">
<script src="../bootstrap-toc.js"></script>

<!-- Font Awesome icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous" />

<!-- clipboard.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script>

<!-- headroom.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script>

<!-- pkgdown -->
<link href="../pkgdown.css" rel="stylesheet">
<script src="../pkgdown.js"></script>




<meta property="og:title" content="Init a dot plot in polar system — polar_init" />
<meta property="og:description" content="Init a dot plot in polar system" />




<!-- mathjax -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script>

<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->



  </head>

  <body data-spy="scroll" data-target="#toc">
    <div class="container template-reference-topic">
      <header>
      <div class="navbar navbar-default navbar-fixed-top" role="navigation">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <span class="navbar-brand">
        <a class="navbar-link" href="../index.html">ggpolar</a>
        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.1</span>
      </span>
    </div>

    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav">
        <li>
  <a href="../index.html">
    <span class="fas fa-home fa-lg"></span>
     
  </a>
</li>
<li>
  <a href="../reference/index.html">Reference</a>
</li>
<li class="dropdown">
  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
    Articles
     
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu" role="menu">
    <li>
      <a href="../articles/surv-corr-connection.html">Polar plot for survival and correlation connection</a>
    </li>
  </ul>
</li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li>
  <a href="https://github.com/ShixiangWang/polar/">
    <span class="fab fa-github fa-lg"></span>
     
  </a>
</li>
      </ul>
      
    </div><!--/.nav-collapse -->
  </div><!--/.container -->
</div><!--/.navbar -->

      

      </header>

<div class="row">
  <div class="col-md-9 contents">
    <div class="page-header">
    <h1>Init a dot plot in polar system</h1>
    <small class="dont-index">Source: <a href='https://github.com/ShixiangWang/polar/blob/master/R/ggpolar.R'><code>R/ggpolar.R</code></a></small>
    <div class="hidden name"><code>polar_init.Rd</code></div>
    </div>

    <div class="ref-description">
    <p>Init a dot plot in polar system</p>
    </div>

    <pre class="usage"><span class='fu'>polar_init</span><span class='op'>(</span><span class='va'>data</span>, <span class='va'>x</span>, <span class='va'>...</span><span class='op'>)</span></pre>

    <h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
    <table class="ref-arguments">
    <colgroup><col class="name" /><col class="desc" /></colgroup>
    <tr>
      <th>data</th>
      <td><p>a <code>data.frame</code> contains all events, e.g., genes.</p></td>
    </tr>
    <tr>
      <th>x</th>
      <td><p>the column name (without quote) storing event list.</p></td>
    </tr>
    <tr>
      <th>...</th>
      <td><p>parameters passing to <a href='https://ggplot2.tidyverse.org/reference/geom_point.html'>ggplot2::geom_point</a>.</p></td>
    </tr>
    </table>

    <h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>

    <p>a <code>ggplot</code> object.</p>

    <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
    <pre class="examples"><span class='r-in'><span class='co'># -------------------</span></span>
<span class='r-in'><span class='co'>#  Init a polar plot</span></span>
<span class='r-in'><span class='co'># -------------------</span></span>
<span class='r-in'></span>
<span class='r-in'><span class='va'>data</span> <span class='op'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/base/data.frame.html'>data.frame</a></span><span class='op'>(</span>x <span class='op'>=</span> <span class='va'>LETTERS</span><span class='op'>[</span><span class='fl'>1</span><span class='op'>:</span><span class='fl'>7</span><span class='op'>]</span><span class='op'>)</span></span>
<span class='r-in'></span>
<span class='r-in'><span class='va'>p1</span> <span class='op'>&lt;-</span> <span class='fu'>polar_init</span><span class='op'>(</span><span class='va'>data</span>, x <span class='op'>=</span> <span class='va'>x</span><span class='op'>)</span></span>
<span class='r-in'><span class='va'>p1</span></span>
<span class='r-plt img'><img src='polar_init-1.png' alt='' width='700' height='433' /></span>
<span class='r-in'></span>
<span class='r-in'><span class='co'># Set aes value</span></span>
<span class='r-in'><span class='va'>p2</span> <span class='op'>&lt;-</span> <span class='fu'>polar_init</span><span class='op'>(</span><span class='va'>data</span>, x <span class='op'>=</span> <span class='va'>x</span>, size <span class='op'>=</span> <span class='fl'>3</span>, color <span class='op'>=</span> <span class='st'>"red"</span>, alpha <span class='op'>=</span> <span class='fl'>0.5</span><span class='op'>)</span></span>
<span class='r-in'><span class='va'>p2</span></span>
<span class='r-plt img'><img src='polar_init-2.png' alt='' width='700' height='433' /></span>
<span class='r-in'></span>
<span class='r-in'><span class='co'># Set aes mapping</span></span>
<span class='r-in'><span class='fu'><a href='https://rdrr.io/r/base/Random.html'>set.seed</a></span><span class='op'>(</span><span class='fl'>123L</span><span class='op'>)</span></span>
<span class='r-in'><span class='va'>data1</span> <span class='op'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/base/data.frame.html'>data.frame</a></span><span class='op'>(</span></span>
<span class='r-in'>  x <span class='op'>=</span> <span class='va'>LETTERS</span><span class='op'>[</span><span class='fl'>1</span><span class='op'>:</span><span class='fl'>7</span><span class='op'>]</span>,</span>
<span class='r-in'>  shape <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span><span class='st'>"r"</span>, <span class='st'>"r"</span>, <span class='st'>"r"</span>, <span class='st'>"b"</span>, <span class='st'>"b"</span>, <span class='st'>"b"</span>, <span class='st'>"b"</span><span class='op'>)</span>,</span>
<span class='r-in'>  color <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span><span class='st'>"r"</span>, <span class='st'>"r"</span>, <span class='st'>"r"</span>, <span class='st'>"b"</span>, <span class='st'>"b"</span>, <span class='st'>"b"</span>, <span class='st'>"b"</span><span class='op'>)</span>,</span>
<span class='r-in'>  size <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/MathFun.html'>abs</a></span><span class='op'>(</span><span class='fu'><a href='https://rdrr.io/r/stats/Normal.html'>rnorm</a></span><span class='op'>(</span><span class='fl'>7</span><span class='op'>)</span><span class='op'>)</span></span>
<span class='r-in'><span class='op'>)</span></span>
<span class='r-in'><span class='co'># Check https://ggplot2.tidyverse.org/reference/geom_point.html</span></span>
<span class='r-in'><span class='co'># for how to use both stroke and color</span></span>
<span class='r-in'><span class='va'>p3</span> <span class='op'>&lt;-</span> <span class='fu'>polar_init</span><span class='op'>(</span><span class='va'>data1</span>, x <span class='op'>=</span> <span class='va'>x</span>, <span class='fu'><a href='https://ggplot2.tidyverse.org/reference/aes.html'>aes</a></span><span class='op'>(</span>size <span class='op'>=</span> <span class='va'>size</span>, color <span class='op'>=</span> <span class='va'>color</span>, shape <span class='op'>=</span> <span class='va'>shape</span><span class='op'>)</span>, alpha <span class='op'>=</span> <span class='fl'>0.5</span><span class='op'>)</span></span>
<span class='r-in'><span class='va'>p3</span></span>
<span class='r-plt img'><img src='polar_init-3.png' alt='' width='700' height='433' /></span>
<span class='r-in'></span>
<span class='r-in'><span class='co'># --------------------</span></span>
<span class='r-in'><span class='co'>#  Connect polar dots</span></span>
<span class='r-in'><span class='co'># --------------------</span></span>
<span class='r-in'><span class='va'>data2</span> <span class='op'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/base/data.frame.html'>data.frame</a></span><span class='op'>(</span></span>
<span class='r-in'>  x1 <span class='op'>=</span> <span class='va'>LETTERS</span><span class='op'>[</span><span class='fl'>1</span><span class='op'>:</span><span class='fl'>7</span><span class='op'>]</span>,</span>
<span class='r-in'>  x2 <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span><span class='st'>"B"</span>, <span class='st'>"C"</span>, <span class='st'>"D"</span>, <span class='st'>"E"</span>, <span class='st'>"C"</span>, <span class='st'>"A"</span>, <span class='st'>"C"</span><span class='op'>)</span>,</span>
<span class='r-in'>  color <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span><span class='st'>"r"</span>, <span class='st'>"r"</span>, <span class='st'>"r"</span>, <span class='st'>"b"</span>, <span class='st'>"b"</span>, <span class='st'>"b"</span>, <span class='st'>"b"</span><span class='op'>)</span></span>
<span class='r-in'><span class='op'>)</span></span>
<span class='r-in'><span class='va'>p4</span> <span class='op'>&lt;-</span> <span class='va'>p3</span> <span class='op'>+</span> <span class='fu'><a href='polar_connect.html'>polar_connect</a></span><span class='op'>(</span><span class='va'>data2</span>, <span class='va'>x1</span>, <span class='va'>x2</span><span class='op'>)</span></span>
<span class='r-in'><span class='va'>p4</span></span>
<span class='r-plt img'><img src='polar_init-4.png' alt='' width='700' height='433' /></span>
<span class='r-in'></span>
<span class='r-in'><span class='co'># Unlike polar_init, mappings don't need to be included in aes()</span></span>
<span class='r-in'><span class='va'>p5</span> <span class='op'>&lt;-</span> <span class='va'>p3</span> <span class='op'>+</span> <span class='fu'><a href='polar_connect.html'>polar_connect</a></span><span class='op'>(</span><span class='va'>data2</span>, <span class='va'>x1</span>, <span class='va'>x2</span>, color <span class='op'>=</span> <span class='va'>color</span>, alpha <span class='op'>=</span> <span class='fl'>0.8</span>, linetype <span class='op'>=</span> <span class='fl'>2</span><span class='op'>)</span></span>
<span class='r-in'><span class='va'>p5</span></span>
<span class='r-plt img'><img src='polar_init-5.png' alt='' width='700' height='433' /></span>
<span class='r-in'></span>
<span class='r-in'><span class='co'># Use two different color scales</span></span>
<span class='r-in'><span class='kw'>if</span> <span class='op'>(</span><span class='fu'><a href='https://rdrr.io/r/base/ns-load.html'>requireNamespace</a></span><span class='op'>(</span><span class='st'>"ggnewscale"</span><span class='op'>)</span><span class='op'>)</span> <span class='op'>{</span></span>
<span class='r-in'>  <span class='kw'><a href='https://rdrr.io/r/base/library.html'>library</a></span><span class='op'>(</span><span class='va'>ggnewscale</span><span class='op'>)</span></span>
<span class='r-in'>  <span class='va'>p6</span> <span class='op'>=</span> <span class='va'>p3</span> <span class='op'>+</span></span>
<span class='r-in'>    <span class='fu'><a href='https://rdrr.io/pkg/ggnewscale/man/new_scale.html'>new_scale</a></span><span class='op'>(</span><span class='st'>"color"</span><span class='op'>)</span> <span class='op'>+</span></span>
<span class='r-in'>    <span class='fu'><a href='polar_connect.html'>polar_connect</a></span><span class='op'>(</span><span class='va'>data2</span>, <span class='va'>x1</span>, <span class='va'>x2</span>, color <span class='op'>=</span> <span class='va'>color</span>, alpha <span class='op'>=</span> <span class='fl'>0.8</span>, linetype <span class='op'>=</span> <span class='fl'>2</span><span class='op'>)</span></span>
<span class='r-in'>  <span class='va'>p6</span> <span class='op'>+</span> <span class='fu'><a href='https://ggplot2.tidyverse.org/reference/scale_brewer.html'>scale_color_brewer</a></span><span class='op'>(</span><span class='op'>)</span></span>
<span class='r-in'>  <span class='va'>p6</span> <span class='op'>+</span> <span class='fu'><a href='https://ggplot2.tidyverse.org/reference/scale_manual.html'>scale_color_manual</a></span><span class='op'>(</span>values <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span><span class='st'>"darkgreen"</span>, <span class='st'>"magenta"</span><span class='op'>)</span><span class='op'>)</span></span>
<span class='r-in'><span class='op'>}</span></span>
<span class='r-plt img'><img src='polar_init-6.png' alt='' width='700' height='433' /></span>
</pre>
  </div>
  <div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
    <nav id="toc" data-toggle="toc" class="sticky-top">
      <h2 data-toc-skip>Contents</h2>
    </nav>
  </div>
</div>


      <footer>
      <div class="copyright">
  <p>Developed by Shixiang Wang.</p>
</div>

<div class="pkgdown">
  <p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.6.1.</p>
</div>

      </footer>
   </div>

  


  </body>
</html>


