<!DOCTYPE html>
<html lang="en">

  <head>

  <!-- Google Analytics + AdThrive -->

<!-- AdThrive Head Tag Manual -->
<script data-no-optimize="1" data-cfasync="false">
    (function(w, d) {
    w.adthrive = w.adthrive || {};
    w.adthrive.cmd = w.
    adthrive.cmd || [];
    w.adthrive.plugin = 'adthrive-ads-manual';
    w.adthrive.host = 'ads.adthrive.com';var s = d.createElement('script');
    s.async = true;
    s.referrerpolicy='no-referrer-when-downgrade';
    s.src = 'https://' + w.adthrive.host + '/sites/6434363fc11d8059e61106b4/ads.min.js?referrer=' + w.encodeURIComponent(w.location.href) + '&cb=' + (Math.floor(Math.random() * 100) + 1);
    var n = d.getElementsByTagName('script')[0];
    n.parentNode.insertBefore(s, n);
    })(window, document);
</script>
<!-- End of AdThrive Head Tag -->

  <script async src="https://www.googletagmanager.com/gtag/js?id=UA-79254642-1"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', 'UA-79254642-1');
    </script>



    <!-- Google Analytics + OutboundLink + Google Adsense -->


    <meta charset="utf-8">
    <title>Area chart &#124; the R Graph Gallery</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="How to build area chart with R. Many examples with explanation and reproducible code, with a focus on ggplot2 and the tidyverse">
    <meta name="keywords" content="Data,Dataviz,Datavisualization,R, ggplot2,tidyverse,area, areachart">
    <meta name="author" content="Yan Holtz">
    <link rel="icon" href="img/logo/R_single_small.png">

    <meta property="og:title" content="Area chart &#124; the R Graph Gallery">
    <meta property="og:image" content="img/overview_RGG.png">
    <meta property="og:description" content="How to build area charts with R. Many examples with explanation and reproducible code, with a focus on ggplot2 and the tidyverse">

    <!-- Bootstrap core CSS -->
    <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom fonts for this template -->
    <link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">





    <!-- Custom styles for this template -->
    <link href="css/agency.css" rel="stylesheet">

    <!-- JQUERY -->
    <script src="vendor/jquery/jquery.min.js"></script>

  </head>

  <body id="page-top">



    <!-- THIS ALLOWS TO INSERT THE MENU THAT IS STORED IN A MENU.HTML FILE-->
    <nav class="navbar navbar-expand-lg fixed-top" id="mainNav"></nav>
    <script>
    $(function(){
      $("#mainNav").load("html_chunk/menu.html");
    });
    </script>

    <!-- THIS ALLOWS TO INSERT THE MODAL OF THE MENU THAT IS STORED IN A MENU_MODAL.HTML FILE-->
    <div id="modal_menu_insertion"> </div>
    <script>
    $(function(){
      $("#modal_menu_insertion").load("html_chunk/menu_modal.html");
    });
    </script>



    <!-- Header -->
    <header class="masthead" style="padding-top: 150px; padding-bottom: 80px">
      <div class="textlanding">
        <h1>Area chart</h1>
        <hr class="short_hr">
          <br>
          <ul class="list-inline social-buttons">
            <li class="list-inline-item">
              <a href="https://twitter.com/R_Graph_Gallery">
                <i class="fa fa-twitter"></i>
              </a>
            </li>
            <li class="list-inline-item social-buttons">
              <a href="https://github.com/holtzy">
                <i class="fa fa-github" style="color: white"></i>
              </a>
            </li>
            <li class="list-inline-item social-buttons">
              <a href="https://www.linkedin.com/in/yan-holtz-2477534a/">
                <i class="fa fa-linkedin"></i>
              </a>
            </li>
          </ul>
          <br><br>
          <p style="max-width: 700px; margin: auto">An <a href="https://www.data-to-viz.com/graph/area.html">area chart</a> represents the evolution of a numeric variable. It is very close to a <a href="line-plot.html">line chart</a>. This section displays many examples built with R and <a href="ggplot2-package.html">ggplot2</a>. Have a look at <a href="https://www.data-to-viz.com/graph/area.html">data-to-viz.com</a> if you want to learn more about area chart theory.</p>
      </div>
    </header>


    <!-- THIS ALLOWS TO INSERT THE ADVERTISEMENT BANNER THAT IS STORED IN A BANNER.HTML FILE-->
    <div id="position_for_images"> </div>
    <script>
    $(function(){
      $("#position_for_images").load("html_chunk/images.html");
    });
    </script>













<!-- ======================== PORTFOLIO SECTION ============================ -->
<!-- Images must be 480 x 480, resize them with ./script_reformat_img.sh output_name.png -->
<section class="bg" id="portfolio" style="padding-top: 10px">
  <div class="container">

    <div class="mySeryTitle">Note on area chart</div>
    <hr>
    <p>This section is tightly linked with other sections. A <a href="line-plot.html">line chart</a> is the same but doesn't fill the surface between the line and the X axis. A <a href="connected-scatterplot.html">connected scatterplot</a> is almost the same thing, but each observation is represented as a dot. More generally, the <a href="time-series.html">time series</a> section can interest you.</p>
    <a class="btn btn-secondary" href="connected-scatterplot.html">connected scatter</a>
    <a class="btn btn-secondary" href="line-plot.html">line chart</a>
    <a class="btn btn-secondary" href="time-series.html">time series</a>


    <br><br><br><br>
    <div class="mySeryTitle">Step by step with <code>ggplot2</code></div>
    <hr>
    <p><code>ggplot2</code> allows to draw line charts thanks to the <code>geom_line()</code> function. It expects as input a data frame with 2 numeric variables, one displayed on each axis. Start your journey with the <a href="line-chart-ggplot2.html">most basic line chart</a>.</p>
    <div id="portfolio-items" class="row">
      <div class="col-md-4 col-sm-6 portfolio-item">
        <a class="portfolio-link" href="164-area-chart-ggplot2.html">
          <div class="portfolio-hover">
            <div class="portfolio-hover-content">
              <p>Most basic</p>
              <hr>
              <p class="explanation_portfolio">Most basic area chart with R and ggplot2</p>
            </div>
          </div>
          <img class="img-fluid imgOfPortfolio" src="img/graph/164-area-chart-ggplot2.png" alt="">
        </a>
      </div>
      <div class="col-md-4 col-sm-6 portfolio-item">
        <a class="portfolio-link" href="164-area-chart-ggplot2.html">
          <div class="portfolio-hover">
            <div class="portfolio-hover-content">
              <p>Improve appearance</p>
              <hr>
              <p class="explanation_portfolio">Use a theme, highlight top line, add points if needed, and more options.</p>
            </div>
          </div>
          <img class="img-fluid imgOfPortfolio" src="img/graph/164-area-chart-ggplot22.png" alt="">
        </a>
      </div>
      <div class="col-md-4 col-sm-6 portfolio-item">
        <a class="portfolio-link" href="line-plot-log-scale.html">
          <div class="portfolio-hover">
            <div class="portfolio-hover-content">
              <p>Log transform</p>
              <hr>
              <p class="explanation_portfolio">How to use a log transformation for the Y axis with scale_x_log10().</p>
            </div>
          </div>
          <img class="img-fluid imgOfPortfolio" src="img/graph/line-plot-log-scale.png" alt="">
        </a>
      </div>
      <div class="col-md-4 col-sm-6 portfolio-item">
        <a class="portfolio-link" href="136-stacked-area-chart.html">
          <div class="portfolio-hover">
            <div class="portfolio-hover-content">
              <p>Most basic</p>
              <hr>
              <p class="explanation_portfolio">Most basic stacked area chart you can build with R and ggplot2, using the geom_area function.</p>
            </div>
          </div>
          <img class="img-fluid imgOfPortfolio" src="img/graph/136-stacked-area-chart1.png" alt="">
        </a>
      </div>
      <div class="col-md-4 col-sm-6 portfolio-item">
        <a class="portfolio-link" href="https://www.data-to-viz.com/caveat/stacking.html">
          <div class="portfolio-hover">
            <div class="portfolio-hover-content">
              <p>Small multiple</p>
              <hr>
              <p class="explanation_portfolio">Small multiple is probably the best alternative, making obvious the evolution of each gropup.</p>
            </div>
          </div>
          <img class="img-fluid imgOfPortfolio" src="img/graph/alternativeStacking2.png" alt="">
        </a>
      </div>
      <div class="col-md-4 col-sm-6 portfolio-item">
        <a class="portfolio-link" href="357-area-chart-with-gradient.html">
          <div class="portfolio-hover">
            <div class="portfolio-hover-content">
              <p>Area chart with gradient color</p>
              <hr>
              <p class="explanation_portfolio">With ggpattern, it's now possible to have not just one color, but a gradient of colors.</p>
            </div>
          </div>
          <img class="img-fluid imgOfPortfolio" src="img/graph/357-area-chart-with-gradient-1.png" alt="">
        </a>
      </div>
      <div class="col-md-4 col-sm-6 portfolio-item">
        <a class="portfolio-link" href="357-area-chart-with-gradient.html">
          <div class="portfolio-hover">
            <div class="portfolio-hover-content">
              <p>Transparent gradient color</p>
              <hr>
              <p class="explanation_portfolio">Here's how to combine a color gradient and transparency against the background in an area chart.</p>
            </div>
          </div>
          <img class="img-fluid imgOfPortfolio" src="img/graph/357-area-chart-with-gradient-2.png" alt="">
        </a>
      </div>
      <div class="col-md-4 col-sm-6 portfolio-item">
        <a class="portfolio-link" href="357-area-chart-with-gradient.html">
          <div class="portfolio-hover">
            <div class="portfolio-hover-content">
              <p>Customized area chart with color gradient</p>
              <hr>
              <p class="explanation_portfolio">An area chart with color gradient, transparency, line chart on top and data points.</p>
            </div>
          </div>
          <img class="img-fluid imgOfPortfolio" src="img/graph/357-area-chart-with-gradient-3.png" alt="">
        </a>
      </div>
    </div>



    <br><br><br><br>
    <div class="mySeryTitle">Interactive version: <code>dygraph</code></div>
    <hr>
    <p>The <code>dygraph</code> package is dedicated to time series visualization. It offers zooming, hovering, minimaps and much more. Visit the <a href="time-series.html">time series</a> section that is dedicated to it for more.</p>
    <a class="btn btn-secondary btn-md text-uppercase" href="318-custom-dygraphs-time-series-example.html">Get code</a>
    <a class="btn btn-secondary btn-md text-uppercase" href="time-series.html">Time series section</a>
    <center><iframe src="HtmlWidget/dygraphs318.html" height="400" width="80%" style="border:none; padding-top: 4px"></iframe></center>


    <br><br><br><br>
    <div class="mySeryTitle">Step by step with base R</div>
    <hr>
    <p>In base R, the combination of the <code>plot()</code> and the <code>polygon()</code> functions allows to build quality area charts.</p>
    <div id="portfolio-items" class="row">
      <div class="col-md-4 col-sm-6 portfolio-item">
        <a class="portfolio-link" href="165-basic-area-chart.html">
          <div class="portfolio-hover">
            <div class="portfolio-hover-content">
              <p>Most basic</p>
              <hr>
              <p class="explanation_portfolio">Most basic area chart you can build in base R using the polygon function.</p>
            </div>
          </div>
          <img class="img-fluid imgOfPortfolio" src="img/graph/165-basic-area-chart.png" alt="">
        </a>
      </div>
    </div>

</section>

<!-- ======================================================================= -->






<!-- ======================== FROM THE WEB SECTION ============================ -->
<section class="bg" id="portfolio" style="padding-top: 10px">
  <div class="container">
    <div class="mySeryTitle">🌐 From the web</div>
    <hr>
    <p>The web is full of astonishing R charts made by awesome bloggers. The <a href="https://www.r-graph-gallery.com">R graph gallery</a> tries to
      display some of the best creations and explain how their source code works. If you want to display your work here, please drop me a word or even better, submit a <a href="https://github.com/holtzy/R-graph-gallery">Pull Request</a>!
    </p>
    <div id="portfolio-items" class="row">
      <div class="col-md-6 col-sm-12">
        <div class="portfolio-item">
          <a class="portfolio-link" href="web-line-chart-with-labels-at-end-of-line.html">
            <div class="portfolio-hover">
              <div class="portfolio-hover-content">
                <p>Line chart with labels</p>
                <hr>
                <p class="explanation_portfolio">It is a common need to display labels at the end of the lines, since that's the place where labels are the more readable. <b>Cédric Scherer</b> gives us a nice walk-through here on how to do it with ggplot2.</p>
              </div>
            </div>
            <img class="img-fluid imgOfPortfolio" src="img/fromTheWeb/web-line-chart-with-labels-at-end-of-line.png" alt="">
          </a>
        </div>
        <div class="portfolio-item">
          <a class="portfolio-link" href="web-lineplots-and-area-chart-the-economist.html">
            <div class="portfolio-hover">
              <div class="portfolio-hover-content">
                <p>Line and Area charts by The Economist</p>
                <hr>
                <p class="explanation_portfolio">Learn how to mimick the style of The Economist with libraries like ggplot2, patchwork, grid, ggtext and more.</p>
              </div>
            </div>
            <img class="img-fluid imgOfPortfolio" src="img/fromTheWeb/web-lineplots-and-area-chart-the-economist.png" alt="">
          </a>
        </div>
      </div>
      <div class="col-md-6 col-sm-12 portfolio-item">
        <a class="portfolio-link" href="web-time-series-and-facetting.html">
          <div class="portfolio-hover">
            <div class="portfolio-hover-content">
              <p>Line chart with filled intersection</p>
              <hr>
              <p class="explanation_portfolio">This example uses geo-faceting: the dataset is split and plotted using geographical regions. For each charts, 2 lines are displayed and the intersection between both is filled.</p>
            </div>
          </div>
          <img class="img-fluid imgOfPortfolio" src="img/fromTheWeb/web-time-series-and-facetting-square.png" alt="line chart with geo-faceting and filled intersection. Made with R and ggplot2">
        </a>
      </div>
      <br/>
      <div class="col-md-6 col-sm-12 portfolio-item">
        <a class="portfolio-link" href="web-stacked-area-chart-inline-labels.html">
          <div class="portfolio-hover">
            <div class="portfolio-hover-content">
              <p>Stacked area chart with clean labels</p>
              <hr>
              <p class="explanation_portfolio">A stacked area chart with a stunning color palette, some well positioned inline labels, some handy vertical annotations and some clean caption text.</p>
            </div>
          </div>
          <img class="img-fluid imgOfPortfolio" src="img/fromTheWeb/web-stacked-area-chart-inline-labels.png" alt="">
        </a>
      </div>
      <br/>
      <div class="col-md-6 col-sm-12 portfolio-item">
        <a class="portfolio-link" href="web-area-chart-with-small-multiple.html">
          <div class="portfolio-hover">
            <div class="portfolio-hover-content">
              <p>Area chart with small multiples</p>
              <hr>
              <p class="explanation_portfolio">Learn how to create an area chart for a large number of categories</p>
            </div>
          </div>
          <img class="img-fluid imgOfPortfolio" src="img/graph/web-area-chart-with-small-multiple.png" alt="">
        </a>
      </div>
    </div> <!-- close portfolio items -->
    </div>
 </div>
</section>
<!-- ======================================================================= -->






<!-- ============================ RELATED SECTION ============================ -->
<section class="bg-light" id="portfolio_landing" style="padding-top: 30px; padding-bottom: 30px; margin-top: 100px;">

  <div class="container">

    <p class="mySeryTitle">Related chart types</p>
    <hr>
    <div class="row">
      <div class="col-md-2 col-sm-4 portfolio-item">
        <a class="portfolio-link"  href="line-plot.html">
          <div class="portfolio-hover">
            <div class="portfolio-hover-content">
              <i class="fa fa-plus fa-3x"></i>
            </div>
          </div>
          <img class="img-fluid" src="img/section/Line150.png" alt="">
        </a>
        <div class="captionPortfolio">Line plot</div>
      </div>
      <div class="col-md-2 col-sm-4 portfolio-item">
        <a class="portfolio-link"  href="area-chart.html">
          <div class="portfolio-hover">
            <div class="portfolio-hover-content">
              <i class="fa fa-plus fa-3x"></i>
            </div>
          </div>
          <img class="img-fluid" src="img/section/Area150.png" alt="">
        </a>
        <div class="captionPortfolio">Area</div>
      </div>
      <div class="col-md-2 col-sm-4 portfolio-item">
        <a class="portfolio-link"  href="stacked-area-graph.html">
          <div class="portfolio-hover">
            <div class="portfolio-hover-content">
              <i class="fa fa-plus fa-3x"></i>
            </div>
          </div>
          <img class="img-fluid" src="img/section/StackedArea150.png" alt="">
        </a>
        <div class="captionPortfolio">Stacked area</div>
      </div>
      <div class="col-md-2 col-sm-4 portfolio-item">
        <a class="portfolio-link"  href="streamgraph.html">
          <div class="portfolio-hover">
            <div class="portfolio-hover-content">
              <i class="fa fa-plus fa-3x"></i>
            </div>
          </div>
          <img class="img-fluid" src="img/section/Stream150.png" alt="">
        </a>
        <div class="captionPortfolio">Streamchart</div>
      </div>
      <div class="col-md-2 col-sm-4 portfolio-item">
        <a class="portfolio-link"  href="time-series.html">
          <div class="portfolio-hover">
            <div class="portfolio-hover-content">
              <i class="fa fa-plus fa-3x"></i>
            </div>
          </div>
          <img class="img-fluid" src="img/section/Time150.gif" alt="">
        </a>
        <div class="captionPortfolio">Time Series</div>
      </div>
    </div>

  </div>
</section>








<!-- ============================ CONTACT SECTION ============================ -->

<!-- ANCHOR -->
<a name="contactanchor"></a>

<section id="contact" class="bg" style="background-color: white"></section>

<!-- THIS ALLOWS TO INSERT THE CONTACT CHUNK THAT IS STORED IN A CONTACT.HTML FILE-->
<script>
$(function(){
  $("#contact").load("html_chunk/contact.html");
});
</script>





<!-- ============================ FOOTER SECTION ============================ -->

    <!-- AdThrive Footer Code Start-->
    <script type="text/javascript" async src="https://btloader.com/tag?o=5698917485248512&upapi=true&domain=r-graph-gallery.com"></script>
    <script>!function(){"use strict";var e;e=document,function(){var t,n;function r(){var t=e.createElement("script");t.src="https://cafemedia-com.videoplayerhub.com/galleryplayer.js",e.head.appendChild(t)}function a(){var t=e.cookie.match("(^|[^;]+)\s*__adblocker\s*=\s*([^;]+)");return t&&t.pop()}function c(){clearInterval(n)}return{init:function(){var e;"true"===(t=a())?r():(e=0,n=setInterval((function(){100!==e&&"false" !== t || c(), "true" === t && (r(), c()), t = a(), e++}), 50))}}}().init()}();</script>
    <!-- AdThrive Footer Code End -->



<footer class="bg-light" id="myFooter"></footer>

<!-- THIS ALLOWS TO INSERT THE FOOTER THAT IS STORED IN A FOOTER.HTML FILE-->
<script>
$(function(){
  $("#myFooter").load("html_chunk/footer.html");
});
</script>

<!-- ============================ -->














<!-- =============== JAVASCRIPT SECTION =============== -->

    <!-- Bootstrap core JavaScript -->
    <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

    <!-- Plugin JavaScript -->
    <script src="vendor/jquery-easing/jquery.easing.min.js"></script>





    <!-- Custom scripts for this template -->
    <script src="js/agency.min.js"></script>




<!--============================== -->



  </body>

</html>