<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><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>word cloud text geoms — geom_text_wordcloud • ggwordcloud</title><!-- favicons --><link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png"><link rel="icon" type="image/png" sizes="32x32" href="../favicon-32x32.png"><link rel="apple-touch-icon" type="image/png" sizes="180x180" href="../apple-touch-icon.png"><link rel="apple-touch-icon" type="image/png" sizes="120x120" href="../apple-touch-icon-120x120.png"><link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png"><link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png"><!-- jquery --><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js" integrity="sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g==" crossorigin="anonymous" referrerpolicy="no-referrer"></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="word cloud text geoms — geom_text_wordcloud"><meta property="og:description" content="geom_text_wordcloud adds text to the plot using a variation of the
wordcloud2.js algorithm. The texts are layered around a spiral centred on
the original position. This geom is based on
geom_text_repel which in turn is based on
geom_text. See the documentation for those functions
for more details. By default, the font size is directly linked to the size
aesthetic. geom_text_wordcloud_area is an alias, with a different set
of default, that chooses a font size so that the area of the text given by the label
aesthetic is linked to the size aesthetic. You can also specify a label_content aesthetic
that overrides the label after its has been used to choose the font size."><meta property="og:image" content="/logo.png"><!-- 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">ggwordcloud</a>
        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="">0.6.2</span>
      </span>
    </div>

    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav"><li>
  <a href="../articles/ggwordcloud.html">Get started</a>
</li>
<li>
  <a href="../reference/index.html">Reference</a>
</li>
<li>
  <a href="../news/index.html">Changelog</a>
</li>
      </ul><ul class="nav navbar-nav navbar-right"><li>
  <a href="https://github.com/lepennec/ggwordcloud/" class="external-link">
    <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>word cloud text geoms</h1>
    <small class="dont-index">Source: <a href="https://github.com/lepennec/ggwordcloud/blob/HEAD/R/geom-text-wordcloud.R" class="external-link"><code>R/geom-text-wordcloud.R</code></a></small>
    <div class="hidden name"><code>geom_text_wordcloud.Rd</code></div>
    </div>

    <div class="ref-description">
    <p><code>geom_text_wordcloud</code> adds text to the plot using a variation of the
wordcloud2.js algorithm. The texts are layered around a spiral centred on
the original position. This geom is based on
<code><a href="https://ggrepel.slowkow.com/reference/geom_text_repel.html" class="external-link">geom_text_repel</a></code> which in turn is based on
<code><a href="https://ggplot2.tidyverse.org/reference/geom_text.html" class="external-link">geom_text</a></code>. See the documentation for those functions
for more details. By default, the font size is directly linked to the size
aesthetic. <code>geom_text_wordcloud_area</code> is an alias, with a different set
of default, that chooses a font size so that the area of the text given by the label
aesthetic is linked to the size aesthetic. You can also specify a label_content aesthetic
that overrides the label after its has been used to choose the font size.</p>
    </div>

    <div id="ref-usage">
    <div class="sourceCode"><pre class="sourceCode r"><code><span><span class="fu">geom_text_wordcloud</span><span class="op">(</span></span>
<span>  mapping <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  data <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  stat <span class="op">=</span> <span class="st">"identity"</span>,</span>
<span>  position <span class="op">=</span> <span class="st">"identity"</span>,</span>
<span>  <span class="va">...</span>,</span>
<span>  parse <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  nudge_x <span class="op">=</span> <span class="fl">0</span>,</span>
<span>  nudge_y <span class="op">=</span> <span class="fl">0</span>,</span>
<span>  eccentricity <span class="op">=</span> <span class="fl">0.65</span>,</span>
<span>  rstep <span class="op">=</span> <span class="fl">0.01</span>,</span>
<span>  tstep <span class="op">=</span> <span class="fl">0.02</span>,</span>
<span>  perc_step <span class="op">=</span> <span class="fl">0.01</span>,</span>
<span>  max_steps <span class="op">=</span> <span class="fl">10</span>,</span>
<span>  grid_size <span class="op">=</span> <span class="fl">4</span>,</span>
<span>  max_grid_size <span class="op">=</span> <span class="fl">128</span>,</span>
<span>  grid_margin <span class="op">=</span> <span class="fl">1</span>,</span>
<span>  xlim <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="cn">NA</span>, <span class="cn">NA</span><span class="op">)</span>,</span>
<span>  ylim <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="cn">NA</span>, <span class="cn">NA</span><span class="op">)</span>,</span>
<span>  seed <span class="op">=</span> <span class="cn">NA</span>,</span>
<span>  rm_outside <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  shape <span class="op">=</span> <span class="st">"circle"</span>,</span>
<span>  mask <span class="op">=</span> <span class="cn">NA</span>,</span>
<span>  area_corr <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  na.rm <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  show.legend <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  inherit.aes <span class="op">=</span> <span class="cn">TRUE</span>,</span>
<span>  show_boxes <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  use_richtext <span class="op">=</span> <span class="cn">TRUE</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="fu">geom_text_wordcloud_area</span><span class="op">(</span></span>
<span>  mapping <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  data <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  stat <span class="op">=</span> <span class="st">"identity"</span>,</span>
<span>  position <span class="op">=</span> <span class="st">"identity"</span>,</span>
<span>  <span class="va">...</span>,</span>
<span>  parse <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  nudge_x <span class="op">=</span> <span class="fl">0</span>,</span>
<span>  nudge_y <span class="op">=</span> <span class="fl">0</span>,</span>
<span>  eccentricity <span class="op">=</span> <span class="fl">0.65</span>,</span>
<span>  rstep <span class="op">=</span> <span class="fl">0.01</span>,</span>
<span>  tstep <span class="op">=</span> <span class="fl">0.02</span>,</span>
<span>  perc_step <span class="op">=</span> <span class="fl">0.01</span>,</span>
<span>  max_steps <span class="op">=</span> <span class="fl">10</span>,</span>
<span>  grid_size <span class="op">=</span> <span class="fl">4</span>,</span>
<span>  max_grid_size <span class="op">=</span> <span class="fl">128</span>,</span>
<span>  grid_margin <span class="op">=</span> <span class="fl">1</span>,</span>
<span>  xlim <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="cn">NA</span>, <span class="cn">NA</span><span class="op">)</span>,</span>
<span>  ylim <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="cn">NA</span>, <span class="cn">NA</span><span class="op">)</span>,</span>
<span>  seed <span class="op">=</span> <span class="cn">NA</span>,</span>
<span>  rm_outside <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  shape <span class="op">=</span> <span class="st">"circle"</span>,</span>
<span>  mask <span class="op">=</span> <span class="cn">NA</span>,</span>
<span>  area_corr <span class="op">=</span> <span class="cn">TRUE</span>,</span>
<span>  na.rm <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  show.legend <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  inherit.aes <span class="op">=</span> <span class="cn">TRUE</span>,</span>
<span>  show_boxes <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  use_richtext <span class="op">=</span> <span class="cn">TRUE</span></span>
<span><span class="op">)</span></span></code></pre></div>
    </div>

    <div id="arguments">
    <h2>Arguments</h2>
    <dl><dt>mapping</dt>
<dd><p>Set of aesthetic mappings created by
<code><a href="https://ggplot2.tidyverse.org/reference/aes.html" class="external-link">aes</a></code> or <code><a href="https://ggplot2.tidyverse.org/reference/aes_.html" class="external-link">aes_</a></code>. If specified and
<code>inherit.aes = TRUE</code> (the default), is combined with the default
mapping at the top level of the plot. You only need to supply
<code>mapping</code> if there isn't a mapping defined for the plot. Note that if
not specified both x and y are set to 0.5, i.e. the middle of the default
panel. Two non classic aesthetics are defined <code>angle_group</code> and
<code>mask_group</code> which define groups used respectively to use different
angular sector and different masks in the word cloud.</p></dd>


<dt>data</dt>
<dd><p>A data frame. If specified, overrides the default data frame
defined at the top level of the plot.</p></dd>


<dt>stat</dt>
<dd><p>The statistical transformation to use on the data for this layer,
as a string.</p></dd>


<dt>position</dt>
<dd><p>Position adjustment, either as a string, or the result of a
call to a position adjustment function.</p></dd>


<dt>...</dt>
<dd><p>other arguments passed on to <code><a href="https://ggplot2.tidyverse.org/reference/layer.html" class="external-link">layer</a></code>. There
are three types of arguments you can use here:</p><ul><li><p>Aesthetics:
to set an aesthetic to a fixed value, like <code>colour = "red"</code> or
<code>size = 3</code>.</p></li>
<li><p>Other arguments to the layer, for example you
override the default <code>stat</code> associated with the layer.</p></li>
<li><p>Other
arguments passed on to the stat.</p></li>
</ul></dd>


<dt>parse</dt>
<dd><p>If <code>TRUE</code>, the labels will be parsed into expressions and
displayed as described in ?plotmath</p></dd>


<dt>nudge_x, nudge_y</dt>
<dd><p>Horizontal and vertical adjustments to nudge the
starting position of each text label.</p></dd>


<dt>eccentricity</dt>
<dd><p>eccentricity of the spiral. Default to .65</p></dd>


<dt>rstep</dt>
<dd><p>relative wordcloud spiral radius increment after one full
rotation. Default to .01.</p></dd>


<dt>tstep</dt>
<dd><p>wordcloud spiral angle increment at each step. Default to .02.</p></dd>


<dt>perc_step</dt>
<dd><p>parameter used to define the minimal distance between two
successive candidate positions on the ellipse. Default to .01</p></dd>


<dt>max_steps</dt>
<dd><p>maximum number of steps avoided thanks to this minimal
criterion. Default to 10. Set to 1 to recover the previous behavior</p></dd>


<dt>grid_size</dt>
<dd><p>grid size used when creating the text bounding boxes.
Default to 4</p></dd>


<dt>max_grid_size</dt>
<dd><p>maximum size of the bounding boxes. Default to 128</p></dd>


<dt>grid_margin</dt>
<dd><p>safety margin around the texts. Default to 1.</p></dd>


<dt>xlim, ylim</dt>
<dd><p>Limits for the x and y axes. Text labels will be constrained
to these limits. By default, text labels are constrained to the entire plot
area.</p></dd>


<dt>seed</dt>
<dd><p>Random seed passed to <code>set.seed</code>. Defaults to <code>NA</code>,
which means that <code>set.seed</code> will not be called.</p></dd>


<dt>rm_outside</dt>
<dd><p>Remove the texts that could not be fitted. Default to
<code>FALSE</code></p></dd>


<dt>shape</dt>
<dd><p>select the shape of the clouds among <code>circle</code>,
<code>cardioid</code>, <code>diamond</code>, <code>square</code>, <code>triangle-forward</code>,
<code>triangle-upright</code>, <code>pentagon</code>, <code>star</code>. Default to
<code>circle</code></p></dd>


<dt>mask</dt>
<dd><p>a mask (or a list of masks) used to define a zone in which the
text should be placed. Each mask should be coercible to a raster in which
non full transparency defined the text zone. When a list of masks is given, the
mask_group aesthetic defines which mask is going to be used. Default to
<code>NA</code>, i.e. no mask.</p></dd>


<dt>area_corr</dt>
<dd><p>Set the font size so that the area is proportional to size
aesthetic  when the scale_size_area is used. As
this is not the classical choice, the default is <code>FALSE</code> so that, by
default, the length of the text is not taken into account.
<code>geom_text_wordcloud_area</code> set this to <code>TRUE</code> by default.</p></dd>


<dt>na.rm</dt>
<dd><p>Remove missing values if TRUE</p></dd>


<dt>show.legend</dt>
<dd><p>is set by default to <code>FALSE</code></p></dd>


<dt>inherit.aes</dt>
<dd><p>Inherits aesthetics if TRUE</p></dd>


<dt>show_boxes</dt>
<dd><p>display the bounding boxes used in the placement algorithm is set
to <code>TRUE</code>. Default to <code>FALSE</code>.</p></dd>


<dt>use_richtext</dt>
<dd><p>use the enhanced gridtext text grob instead of the grid one. Allow to
use markdown/html syntax in label. Default to <code>TRUE</code>.</p></dd>

</dl></div>
    <div id="value">
    <h2>Value</h2>
    

<p>a ggplot</p>
    </div>

    <div id="ref-examples">
    <h2>Examples</h2>
    <div class="sourceCode"><pre class="sourceCode r"><code><span class="r-in"><span><span class="fu"><a href="https://rdrr.io/r/base/Random.html" class="external-link">set.seed</a></span><span class="op">(</span><span class="fl">42</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://rdrr.io/r/utils/data.html" class="external-link">data</a></span><span class="op">(</span><span class="st">"love_words_latin_small"</span><span class="op">)</span></span></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/ggplot.html" class="external-link">ggplot</a></span><span class="op">(</span><span class="va">love_words_latin_small</span>, <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes.html" class="external-link">aes</a></span><span class="op">(</span>label <span class="op">=</span> <span class="va">word</span>, size <span class="op">=</span> <span class="va">speakers</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span></span></span>
<span class="r-in"><span><span class="fu">geom_text_wordcloud</span><span class="op">(</span><span class="op">)</span> <span class="op">+</span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/scale_size.html" class="external-link">scale_size_area</a></span><span class="op">(</span>max_size <span class="op">=</span> <span class="fl">20</span><span class="op">)</span> <span class="op">+</span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/ggtheme.html" class="external-link">theme_minimal</a></span><span class="op">(</span><span class="op">)</span></span></span>
<span class="r-plt img"><img src="geom_text_wordcloud-1.png" alt="" width="700" height="433"></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/ggplot.html" class="external-link">ggplot</a></span><span class="op">(</span><span class="va">love_words_latin_small</span>, <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes.html" class="external-link">aes</a></span><span class="op">(</span>label <span class="op">=</span> <span class="va">word</span>, size <span class="op">=</span> <span class="va">speakers</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span></span></span>
<span class="r-in"><span><span class="fu">geom_text_wordcloud_area</span><span class="op">(</span><span class="op">)</span> <span class="op">+</span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/scale_size.html" class="external-link">scale_size_area</a></span><span class="op">(</span>max_size <span class="op">=</span> <span class="fl">20</span><span class="op">)</span> <span class="op">+</span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/ggtheme.html" class="external-link">theme_minimal</a></span><span class="op">(</span><span class="op">)</span></span></span>
<span class="r-plt img"><img src="geom_text_wordcloud-2.png" alt="" width="700" height="433"></span>
</code></pre></div>
    </div>
  </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></p><p>Developed by Erwan Le Pennec, Kamil Slowikowski.</p>
</div>

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

      </footer></div>

  


  

  </body></html>

