<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />



<title>ggplot2 extensions: ggnetwork</title>

<script src="libs/jquery-1.11.0/jquery.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="libs/bootstrap-3.3.1/css/cosmo.min.css" rel="stylesheet" />
<script src="libs/bootstrap-3.3.1/js/bootstrap.min.js"></script>
<script src="libs/bootstrap-3.3.1/shim/html5shiv.min.js"></script>
<script src="libs/bootstrap-3.3.1/shim/respond.min.js"></script>

<!-- Styles for this site -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/styles.css" rel="stylesheet">


<!-- Polyfill JS -->
<script src="js/polyfill.js"></script>

<style type="text/css">code{white-space: pre;}</style>
<link rel="stylesheet"
      href="libs/highlight/textmate.css"
      type="text/css" />
<script src="libs/highlight/highlight.js"></script>
<style type="text/css">
  pre:not([class]) {
    background-color: white;
  }
</style>
<script type="text/javascript">
if (window.hljs && document.readyState && document.readyState === "complete") {
   window.setTimeout(function() {
      hljs.initHighlighting();
   }, 0);
}
</script>



</head>

<body>

<style type = "text/css">
.main-container {
  max-width: 940px;
  margin-left: auto;
  margin-right: auto;
}
code {
  color: inherit;
  background-color: rgba(0, 0, 0, 0.04);
}
img { 
  max-width:100%; 
  height: auto; 
}
</style>
<div class="container-fluid main-container">

<!--html_preserve-->

<div class="header">
  <nav class="navbar">
      <h3 class="navbar-left"><strong>ggplot2</strong> extensions</h3>
      <ul class="nav nav-pills navbar-right">
        <li role="presentation" id="nav-home"><a href="index.html">Home</a></li>
        <li role="presentation" id="nav-showcase"><a href="ggiraph.html">Extensions</a></li>
        <li role="presentation" id="nav-github"><a href="https://github.com/ggplot2-exts/ggplot2-exts.github.io">GitHub</a></li>
      </ul>
  </nav>
</div>

<div class="showcase-header">

  <div id = "showcase-intro">
    ggplot2 now has an official extension mechanism. This means that others can now easily create their own stats, geoms and positions, and provide them in other packages. This should allow the ggplot2 community to flourish, even as less development work happens in ggplot2 itself. This page showcases these extensions.
  </div>

<div class="container-fluid">
  <div class="row">

    <div class="col-sm-4">
      <div class="list-group">
        <a href="ggiraph.html" class="list-group-item">
          <h5 class="list-group-item-heading">ggiraph</h5>
          <p class="list-group-item-text">Make ggplot interactive</p>
        </a>
        <a href="ggstance.html" class="list-group-item">
          <h5 class="list-group-item-heading">ggstance</h5>
          <p class="list-group-item-text">Horizontal versions of ggplot2 geoms</p>
        </a>
        
        <a href="ggalt.html" class="list-group-item">
          <h5 class="list-group-item-heading">ggalt</h5>
          <p class="list-group-item-text">Extra coordinate systems, geoms & stats</p>
        </a>
        
        <a href="ggforce.html" class="list-group-item">
          <h5 class="list-group-item-heading">ggforce</h5>
          <p class="list-group-item-text">Accelarating ggplot2</p>
        </a>
        
        <a href="ggrepel.html" class="list-group-item">
          <h5 class="list-group-item-heading">ggrepel</h5>
          <p class="list-group-item-text">Repel overlapping text labels</p>
        </a>
        
        <a href="ggraph.html" class="list-group-item">
          <h5 class="list-group-item-heading">ggraph</h5>
          <p class="list-group-item-text">Plot graph-like data structures</p>
        </a>
        
        <a href="ggpmisc.html" class="list-group-item">
          <h5 class="list-group-item-heading">ggpmisc</h5>
          <p class="list-group-item-text">Miscellaneous extensions to ggplot2</p>
        </a>
        
        <a href="geomnet.html" class="list-group-item">
          <h5 class="list-group-item-heading">geomnet</h5>
          <p class="list-group-item-text">Network visualizations in ggplot2</p>
        </a>
        <a href="ggExtra.html" class="list-group-item">
          <h5 class="list-group-item-heading">ggExtra</h5>
          <p class="list-group-item-text">Marginal density plots or histograms</p>
        </a>
        <a href="gganimate.html" class="list-group-item">
          <h5 class="list-group-item-heading">gganimate</h5>
          <p class="list-group-item-text">Create easy animations with ggplot2</p>
        </a>
        <a href="plotROC.html" class="list-group-item">
          <h5 class="list-group-item-heading">plotROC</h5>
          <p class="list-group-item-text">Interactive ROC plots</p>
        </a>
        <a href="ggthemes.html" class="list-group-item">
          <h5 class="list-group-item-heading">ggthemes</h5>
          <p class="list-group-item-text">ggplot themes and scales</p>
        </a>
        <a href="ggspectra.html" class="list-group-item">
          <h5 class="list-group-item-heading">ggspectra</h5>
          <p class="list-group-item-text">Extensions for radiation spectra</p>
        </a>
        <a href="ggnetwork.html" class="list-group-item">
          <h5 class="list-group-item-heading">ggnetwork</h5>
          <p class="list-group-item-text">Geoms to plot networks with ggplot2</p>
        </a>
        <a href="ggtech.html" class="list-group-item">
          <h5 class="list-group-item-heading">ggtech</h5>
          <p class="list-group-item-text">ggplot2 tech themes, scales, and geoms</p>
        </a>
        <a href="ggradar.html" class="list-group-item">
          <h5 class="list-group-item-heading">ggradar</h5>
          <p class="list-group-item-text">radar charts with ggplot2</p>
        </a>
        <a href="ggTimeSeries.html" class="list-group-item">
          <h5 class="list-group-item-heading">ggTimeSeries</h5>
          <p class="list-group-item-text">Time series visualisations</p>
        </a>
        <a href="ggtree.html" class="list-group-item">
          <h5 class="list-group-item-heading">ggtree</h5>
          <p class="list-group-item-text">A phylogenetic tree viewer</p>
        </a>
        <a href="ggseas.html" class="list-group-item">
          <h5 class="list-group-item-heading">ggseas</h5>
          <p class="list-group-item-text">Seasonal adjustment on the fly</p>
        </a>
         
        

      </div> <!-- list-group -->

    </div> <!-- col-sm-4 -->

    <div id="ggnetwork" class="col-sm-8">
<h3>ggnetwork</h3>
<p><a href="https://github.com/briatte/ggnetwork" class="uri">https://github.com/briatte/ggnetwork</a></p>
<p>The ggnetwork package provides a way to build network plots with ggplot2.</p>
<pre class="r"><code># Example from https://briatte.github.io/ggnetwork/
library(ggplot2)
library(ggnetwork)

# Let’s define a small random graph to illustrate each component of ggnetwork:
library(network)
library(sna)
n = network(rgraph(10, tprob = 0.2), directed = FALSE)

# Let’s now add categorical and continuous attributes for both edges and vertices
n %v% &quot;family&quot; = sample(letters[1:3], 10, replace = TRUE)
n %v% &quot;importance&quot; = sample(1:3, 10, replace = TRUE)

# We now add a categorical edge attribute called &quot;type&quot;, 
# which is set to either &quot;x&quot;, &quot;y&quot; or &quot;z&quot;, and a continuous vertex 
# attribute called &quot;day&quot;, which is set to either 1, 2 or 3.
e = network.edgecount(n)
set.edge.attribute(n, &quot;type&quot;, sample(letters[24:26], e, replace = TRUE))
set.edge.attribute(n, &quot;day&quot;, sample(1:3, e, replace = TRUE))

# Let’s now draw the network edges using geom_edges
# theme_blank
ggplot(data = ggnetwork(n), aes(x = x, y = y, xend = xend, yend = yend)) +
  geom_edges(aes(linetype = type), color = &quot;grey50&quot;) +
  theme_blank()</code></pre>
<p><img src="ggnetwork_files/figure-html/unnamed-chunk-1-1.png" title="" alt="" width="576" /></p>
<pre class="r"><code># Let’s now draw the nodes using geom_nodes
ggplot(data = ggnetwork(n), aes(x = x, y = y, xend = xend, yend = yend)) +
  geom_edges(aes(linetype = type), color = &quot;grey50&quot;) +
  geom_nodes(aes(color = family, size = importance)) +
  theme_blank()</code></pre>
<p><img src="ggnetwork_files/figure-html/unnamed-chunk-1-2.png" title="" alt="" width="576" /></p>
<pre class="r"><code># Let’s now add node labels.
ggplot(data = ggnetwork(n), aes(x = x, y = y, xend = xend, yend = yend)) +
  geom_edges(color = &quot;black&quot;) +
  geom_nodes(color = &quot;black&quot;, size = 8) +
  geom_nodetext(aes(color = family, label = LETTERS[ vertex.names ]), fontface = &quot;bold&quot;) +
  theme_blank()</code></pre>
<p><img src="ggnetwork_files/figure-html/unnamed-chunk-1-3.png" title="" alt="" width="576" /></p>
</div> <!-- col-sm-8 -->

  </div> <!-- row -->
</div>

</div> <!-- showcase-header -->



<!--/html_preserve-->







</div> <!-- page-body -->

<footer>
  <div>&nbsp;</div>
  <div>&nbsp;</div>
  <div class="text-muted">
  Design inspired by <a href="http://www.htmlwidgets.org/index.html" target="_blank">Ramnath Vaidyanathan, Kenton Russell, and RStudio, Inc</a>.
  </div>
  <div class="text-muted">
  Maintained by <a href="http://www.danielemaasit.com" target="_blank">Daniel Emaasit</a>.
  </div>
  <div class="text-muted">
  Copyright &copy; 2016 The R Community.
  </div>
</footer>

<script>
// manage active state of headres and navigation based on current page

$(document).ready(function () {
  
  // compute name of page
  href = window.location.pathname;
  href = href.substr(href.lastIndexOf('/') + 1);
  if (href == "")
    href = "index.html";
  
  // main navigation and headers
  if (href.startsWith("index")) {
    $('#nav-home').addClass('active');
    $('.title').addClass('hidden');
  } else if (href.startsWith("showcase")) {
    $('#nav-showcase').addClass('active');
    $("#page-body").detach().appendTo('#showcase-body');
    $('.showcase-header').removeClass('hidden');
    $('.title').addClass('hidden');
  } else if (href.startsWith("develop")) {
    $('#nav-develop').addClass('active');
  }
     
  // submenu navigation (used by showcase and develop)
  $('.list-group a[href="' + href + '"]').addClass('active');      
});

</script>

</div>

<script>

// add bootstrap table styles to pandoc tables
$(document).ready(function () {
  $('tr.header').parent('thead').parent('table').addClass('table table-condensed');
});

</script>


</body>
</html>