{"id":15911,"date":"2020-04-27T16:18:55","date_gmt":"2020-04-27T15:18:55","guid":{"rendered":"https:\/\/www.datanovia.com\/en\/?post_type=dt_lessons&#038;p=15911"},"modified":"2020-04-27T16:28:05","modified_gmt":"2020-04-27T15:28:05","slug":"highchart-interactive-area-plot-in-r","status":"publish","type":"dt_lessons","link":"https:\/\/www.datanovia.com\/en\/lessons\/highchart-interactive-area-plot-in-r\/","title":{"rendered":"Highchart Interactive Area Plot in R"},"content":{"rendered":"<div id=\"rdoc\">\n<p>This article describes how to create <strong>interactive area plots<\/strong> using the highcharter R package.<\/p>\n<p>Contents:<\/p>\n<div id=\"TOC\">\n<ul>\n<li><a href=\"#loading-required-r-packages\">Loading required R packages<\/a><\/li>\n<li><a href=\"#data-preparation\">Data preparation<\/a><\/li>\n<li><a href=\"#basic-area-plots\">Basic area plots<\/a><\/li>\n<li><a href=\"#area-plot-with-multiple-groups\">Area plot with multiple groups<\/a><\/li>\n<li><a href=\"#spline-line-with-polynomial-interpolation\">Spline: Line with polynomial interpolation<\/a><\/li>\n<\/ul>\n<\/div>\n<div id=\"loading-required-r-packages\" class=\"section level2\">\n<h2>Loading required R packages<\/h2>\n<pre class=\"r\"><code>library(tidyverse)\r\nlibrary(highcharter) <\/code><\/pre>\n<\/div>\n<div id=\"data-preparation\" class=\"section level2\">\n<h2>Data preparation<\/h2>\n<pre class=\"r\"><code>data(\"diamonds\", package = \"ggplot2\")\r\n\r\ndf &lt;- diamonds %&gt;%\r\n  group_by(cut)%&gt;%\r\n  count()\r\nhead(df, 4)<\/code><\/pre>\n<pre><code>## # A tibble: 4 x 2\r\n## # Groups:   cut [4]\r\n##   cut           n\r\n##   &lt;ord&gt;     &lt;int&gt;\r\n## 1 Fair       1610\r\n## 2 Good       4906\r\n## 3 Very Good 12082\r\n## 4 Premium   13791<\/code><\/pre>\n<pre class=\"r\"><code>df2 &lt;- diamonds %&gt;%\r\n  group_by(cut, color)%&gt;%\r\n  count()\r\nhead(df2, 4)<\/code><\/pre>\n<pre><code>## # A tibble: 4 x 3\r\n## # Groups:   cut, color [4]\r\n##   cut   color     n\r\n##   &lt;ord&gt; &lt;ord&gt; &lt;int&gt;\r\n## 1 Fair  D       163\r\n## 2 Fair  E       224\r\n## 3 Fair  F       312\r\n## 4 Fair  G       314<\/code><\/pre>\n<\/div>\n<div id=\"basic-area-plots\" class=\"section level2\">\n<h2>Basic area plots<\/h2>\n<pre class=\"r\"><code>hc &lt;- df %&gt;% \r\n  hchart(\r\n  'area', hcaes(x = cut, y = n),\r\n  color = \"steelblue\"\r\n  ) <\/code><\/pre>\n<pre class=\"r\"><code>hc<\/code><\/pre>\n<p><iframe width=\"95%\" height=\"450\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/highcharter\/figures\/020-highcharter-area-plot-basic-area-plots.html\" frameborder=\"2\"><br \/>\n<\/iframe><\/p>\n<\/div>\n<div id=\"area-plot-with-multiple-groups\" class=\"section level2\">\n<h2>Area plot with multiple groups<\/h2>\n<pre class=\"r\"><code>hc &lt;- df2 %&gt;% \r\n  hchart('area', hcaes(x = 'cut', y = 'n', group = \"color\"))<\/code><\/pre>\n<pre class=\"r\"><code>hc<\/code><\/pre>\n<p><iframe width=\"95%\" height=\"450\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/highcharter\/figures\/020-highcharter-area-plot-area-plot-with-multiple-groups.html\" frameborder=\"2\"><br \/>\n<\/iframe><\/p>\n<\/div>\n<div id=\"spline-line-with-polynomial-interpolation\" class=\"section level2\">\n<h2>Spline: Line with polynomial interpolation<\/h2>\n<pre class=\"r\"><code>hc &lt;- df2 %&gt;% \r\n  hchart('areaspline', hcaes(x = 'cut', y = 'n', group = \"color\"))<\/code><\/pre>\n<pre class=\"r\"><code>hc<\/code><\/pre>\n<p><iframe width=\"95%\" height=\"450\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/highcharter\/figures\/020-highcharter-area-plot-spline-plot.html\" frameborder=\"2\"><br \/>\n<\/iframe><\/p>\n<\/div>\n<\/div>\n<p><!--end rdoc--><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Describes how to create interactive area plots using the highcharter R package<\/p>\n","protected":false},"author":1,"featured_media":9150,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","class_list":["post-15911","dt_lessons","type-dt_lessons","status-publish","has-post-thumbnail","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Highchart Interactive Area Plot in R: The Essentials - Datanovia<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.datanovia.com\/en\/lessons\/highchart-interactive-area-plot-in-r\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Highchart Interactive Area Plot in R: The Essentials - Datanovia\" \/>\n<meta property=\"og:description\" content=\"Describes how to create interactive area plots using the highcharter R package\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.datanovia.com\/en\/lessons\/highchart-interactive-area-plot-in-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Datanovia\" \/>\n<meta property=\"article:modified_time\" content=\"2020-04-27T15:28:05+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2019\/05\/P1040271.JPG.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"512\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.datanovia.com\/en\/lessons\/highchart-interactive-area-plot-in-r\/\",\"url\":\"https:\/\/www.datanovia.com\/en\/lessons\/highchart-interactive-area-plot-in-r\/\",\"name\":\"Highchart Interactive Area Plot in R: The Essentials - Datanovia\",\"isPartOf\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/lessons\/highchart-interactive-area-plot-in-r\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/lessons\/highchart-interactive-area-plot-in-r\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2019\/05\/P1040271.JPG.jpg\",\"datePublished\":\"2020-04-27T15:18:55+00:00\",\"dateModified\":\"2020-04-27T15:28:05+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/lessons\/highchart-interactive-area-plot-in-r\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.datanovia.com\/en\/lessons\/highchart-interactive-area-plot-in-r\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.datanovia.com\/en\/lessons\/highchart-interactive-area-plot-in-r\/#primaryimage\",\"url\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2019\/05\/P1040271.JPG.jpg\",\"contentUrl\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2019\/05\/P1040271.JPG.jpg\",\"width\":1024,\"height\":512},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.datanovia.com\/en\/lessons\/highchart-interactive-area-plot-in-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.datanovia.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Lessons\",\"item\":\"https:\/\/www.datanovia.com\/en\/lessons\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Highchart Interactive Area Plot in R\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.datanovia.com\/en\/#website\",\"url\":\"https:\/\/www.datanovia.com\/en\/\",\"name\":\"Datanovia\",\"description\":\"Data Mining and Statistics for Decision Support\",\"publisher\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.datanovia.com\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.datanovia.com\/en\/#organization\",\"name\":\"Datanovia\",\"url\":\"https:\/\/www.datanovia.com\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.datanovia.com\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/09\/datanovia-logo.png\",\"contentUrl\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/09\/datanovia-logo.png\",\"width\":98,\"height\":99,\"caption\":\"Datanovia\"},\"image\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Highchart Interactive Area Plot in R: The Essentials - Datanovia","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.datanovia.com\/en\/lessons\/highchart-interactive-area-plot-in-r\/","og_locale":"en_US","og_type":"article","og_title":"Highchart Interactive Area Plot in R: The Essentials - Datanovia","og_description":"Describes how to create interactive area plots using the highcharter R package","og_url":"https:\/\/www.datanovia.com\/en\/lessons\/highchart-interactive-area-plot-in-r\/","og_site_name":"Datanovia","article_modified_time":"2020-04-27T15:28:05+00:00","og_image":[{"width":1024,"height":512,"url":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2019\/05\/P1040271.JPG.jpg","type":"image\/jpeg"}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.datanovia.com\/en\/lessons\/highchart-interactive-area-plot-in-r\/","url":"https:\/\/www.datanovia.com\/en\/lessons\/highchart-interactive-area-plot-in-r\/","name":"Highchart Interactive Area Plot in R: The Essentials - Datanovia","isPartOf":{"@id":"https:\/\/www.datanovia.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.datanovia.com\/en\/lessons\/highchart-interactive-area-plot-in-r\/#primaryimage"},"image":{"@id":"https:\/\/www.datanovia.com\/en\/lessons\/highchart-interactive-area-plot-in-r\/#primaryimage"},"thumbnailUrl":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2019\/05\/P1040271.JPG.jpg","datePublished":"2020-04-27T15:18:55+00:00","dateModified":"2020-04-27T15:28:05+00:00","breadcrumb":{"@id":"https:\/\/www.datanovia.com\/en\/lessons\/highchart-interactive-area-plot-in-r\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.datanovia.com\/en\/lessons\/highchart-interactive-area-plot-in-r\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.datanovia.com\/en\/lessons\/highchart-interactive-area-plot-in-r\/#primaryimage","url":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2019\/05\/P1040271.JPG.jpg","contentUrl":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2019\/05\/P1040271.JPG.jpg","width":1024,"height":512},{"@type":"BreadcrumbList","@id":"https:\/\/www.datanovia.com\/en\/lessons\/highchart-interactive-area-plot-in-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.datanovia.com\/en\/"},{"@type":"ListItem","position":2,"name":"Lessons","item":"https:\/\/www.datanovia.com\/en\/lessons\/"},{"@type":"ListItem","position":3,"name":"Highchart Interactive Area Plot in R"}]},{"@type":"WebSite","@id":"https:\/\/www.datanovia.com\/en\/#website","url":"https:\/\/www.datanovia.com\/en\/","name":"Datanovia","description":"Data Mining and Statistics for Decision Support","publisher":{"@id":"https:\/\/www.datanovia.com\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.datanovia.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.datanovia.com\/en\/#organization","name":"Datanovia","url":"https:\/\/www.datanovia.com\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.datanovia.com\/en\/#\/schema\/logo\/image\/","url":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/09\/datanovia-logo.png","contentUrl":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/09\/datanovia-logo.png","width":98,"height":99,"caption":"Datanovia"},"image":{"@id":"https:\/\/www.datanovia.com\/en\/#\/schema\/logo\/image\/"}}]}},"multi-rating":{"mr_rating_results":[]},"_links":{"self":[{"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/dt_lessons\/15911","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/dt_lessons"}],"about":[{"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/types\/dt_lessons"}],"author":[{"embeddable":true,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/comments?post=15911"}],"version-history":[{"count":1,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/dt_lessons\/15911\/revisions"}],"predecessor-version":[{"id":15912,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/dt_lessons\/15911\/revisions\/15912"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/media\/9150"}],"wp:attachment":[{"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/media?parent=15911"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}