{"id":15584,"date":"2020-04-01T22:12:12","date_gmt":"2020-04-01T21:12:12","guid":{"rendered":"https:\/\/www.datanovia.com\/en\/?p=15584"},"modified":"2020-04-01T22:12:12","modified_gmt":"2020-04-01T21:12:12","slug":"how-to-create-a-beautiful-plots-in-r-with-summary-statistics-labels","status":"publish","type":"post","link":"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-plots-in-r-with-summary-statistics-labels\/","title":{"rendered":"How to Create a Beautiful Plots in R with Summary Statistics Labels"},"content":{"rendered":"<div id=\"rdoc\">\n<p>You will learn how to create beautiful plots in R and add summary summary statistics table such as sample size (n), median, mean and IQR onto the plot. We will also describes how to create multipanel graphics combined with the summary table. Examples of plots illustrated here, include: box plot, violin plot, bar plot, line plot; etc.<\/p>\n<p>Contents:<\/p>\n<div id=\"TOC\">\n<ul>\n<li><a href=\"#prerequisites\">Prerequisites<\/a><\/li>\n<li><a href=\"#basic-box-plots-with-add-summary-statistics\">Basic box plots with add summary statistics<\/a><\/li>\n<li><a href=\"#grouped-plots-with-summary-table\">Grouped plots with summary table<\/a>\n<ul>\n<li><a href=\"#grouped-box-plots-and-violin-plots\">Grouped box plots and violin plots<\/a><\/li>\n<li><a href=\"#grouped-bar-plots-and-line-plots\">Grouped bar plots and line plots<\/a><\/li>\n<li><a href=\"#three-groups-on-the-x-axis\">Three groups on the x axis<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#multipanel-plots-with-summary-table\">Multipanel plots with summary table<\/a><\/li>\n<li><a href=\"#build-step-by-step-a-custom-multipanel-plot\">Build step by step a custom multipanel plot<\/a><\/li>\n<\/ul>\n<\/div>\n<div id=\"prerequisites\" class=\"section level2\">\n<h2>Prerequisites<\/h2>\n<p>Load required R packages<\/p>\n<pre class=\"r\"><code>library(tidyverse)\r\nlibrary(rstatix)\r\nlibrary(ggpubr)<\/code><\/pre>\n<p>Data preparation:<\/p>\n<pre class=\"r\"><code># Demo data\r\ndata(\"ToothGrowth\")\r\ndf &lt;- ToothGrowth\r\ndf$dose &lt;- as.factor(df$dose)\r\n# Add random QC column\r\nset.seed(123)\r\nqc &lt;- rep(c(\"pass\", \"fail\"), 30)\r\ndf$qc &lt;- as.factor(sample(qc, 60))\r\n# Inspect the data\r\nhead(df)<\/code><\/pre>\n<pre><code>##    len supp dose   qc\r\n## 1  4.2   VC  0.5 fail\r\n## 2 11.5   VC  0.5 pass\r\n## 3  7.3   VC  0.5 fail\r\n## 4  5.8   VC  0.5 pass\r\n## 5  6.4   VC  0.5 pass\r\n## 6 10.0   VC  0.5 pass<\/code><\/pre>\n<\/div>\n<div id=\"basic-box-plots-with-add-summary-statistics\" class=\"section level2\">\n<h2>Basic box plots with add summary statistics<\/h2>\n<p>In the following R code, possible values for the argument <code>ggfunc<\/code> are the ggpubr R package functions, including: <code>ggboxplot<\/code>, <code>ggviolin<\/code>, <code>ggdotplot<\/code>, <code>ggbarplot<\/code>, <code>ggline<\/code>, etc. It can be also any other ggplot function that accepts the following arguments: <code>data, x, color, fill, palette, ggtheme, facet.by<\/code>.<\/p>\n<pre class=\"r\"><code># Basic plot\r\nggsummarystats(\r\n  df, x = \"dose\", y = \"len\", \r\n  ggfunc = ggboxplot, add = \"jitter\"\r\n  )<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/r-tutorial\/figures\/beautiful-plot-in-r-with-summary-statistics-labels-boxplots-with-summary-statistics-1.png\" width=\"480\" \/><\/p>\n<pre class=\"r\"><code># Color by groups\r\nggsummarystats(\r\n  df, x = \"dose\", y = \"len\", \r\n  ggfunc = ggboxplot, add = \"jitter\",\r\n  color = \"dose\", palette = \"npg\"\r\n  )<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/r-tutorial\/figures\/beautiful-plot-in-r-with-summary-statistics-labels-boxplots-with-summary-statistics-2.png\" width=\"480\" \/><\/p>\n<div class=\"block\">\n<p>Note that, you can create step by step your own graph and summary table. The following R code describes how to combine the main graph and the summary table into one figure.<\/p>\n<\/div>\n<pre class=\"r\"><code># Compute summary statistics\r\nsummary.stats &lt;- df %&gt;%\r\n  group_by(dose) %&gt;%\r\n  get_summary_stats() %&gt;%\r\n  select(dose, n, median, iqr)\r\nsummary.stats\r\n\r\n# Create a boxplot\r\nbxp &lt;- ggboxplot(\r\n  df, x = \"dose\", y = \"len\", add = \"jitter\", \r\n  ggtheme = theme_bw()\r\n)\r\n\r\n# Visualize the summary statistics\r\nsummary.plot &lt;- ggsummarytable(\r\n  summary.stats, x = \"dose\", y = c(\"n\", \"median\", \"iqr\"),\r\n  ggtheme = theme_bw()\r\n  ) +\r\n  clean_table_theme()\r\n\r\n# Combine the boxplot and the summary statistics plot\r\nggarrange(\r\n  bxp, summary.plot, ncol = 1, align = \"v\",\r\n  heights = c(0.80, 0.20)\r\n  )<\/code><\/pre>\n<\/div>\n<div id=\"grouped-plots-with-summary-table\" class=\"section level2\">\n<h2>Grouped plots with summary table<\/h2>\n<div id=\"grouped-box-plots-and-violin-plots\" class=\"section level3\">\n<h3>Grouped box plots and violin plots<\/h3>\n<pre class=\"r\"><code># Grouped plots\r\nggsummarystats(\r\n  df, x = \"dose\", y = \"len\", \r\n  ggfunc = ggboxplot, add = \"jitter\",\r\n  color = \"supp\", palette = \"npg\"\r\n  )\r\n\r\n# Change plot type to violin\r\nggsummarystats(\r\n  df, x = \"dose\", y = \"len\", \r\n  ggfunc = ggviolin, add = c(\"jitter\", \"median_iqr\"),\r\n  color = \"supp\", palette = \"npg\"\r\n  )<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/r-tutorial\/figures\/beautiful-plot-in-r-with-summary-statistics-labels-grouped-box-plots-and-violin-plots-1.png\" width=\"336\" \/><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/r-tutorial\/figures\/beautiful-plot-in-r-with-summary-statistics-labels-grouped-box-plots-and-violin-plots-2.png\" width=\"336\" \/><\/p>\n<\/div>\n<div id=\"grouped-bar-plots-and-line-plots\" class=\"section level3\">\n<h3>Grouped bar plots and line plots<\/h3>\n<pre class=\"r\"><code># Create barplot\r\nggsummarystats(\r\n  df, x = \"dose\", y = \"len\", \r\n  ggfunc = ggbarplot, add = c(\"jitter\", \"median_iqr\"), position = position_dodge(),\r\n  color = \"supp\", palette = \"npg\"\r\n  )\r\n\r\n# Create line plots\r\nggsummarystats(\r\n  df, x = \"dose\", y = \"len\", \r\n  ggfunc = ggline, add = c(\"jitter\", \"median_iqr\"), \r\n  color = \"supp\", palette = \"npg\"\r\n  )<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/r-tutorial\/figures\/beautiful-plot-in-r-with-summary-statistics-labels-grouped-bar-plots-and-line-plots-1.png\" width=\"336\" \/><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/r-tutorial\/figures\/beautiful-plot-in-r-with-summary-statistics-labels-grouped-bar-plots-and-line-plots-2.png\" width=\"336\" \/><\/p>\n<\/div>\n<div id=\"three-groups-on-the-x-axis\" class=\"section level3\">\n<h3>Three groups on the x axis<\/h3>\n<pre class=\"r\"><code>ggsummarystats(\r\n  df, x = \"supp\", y = \"len\", \r\n  ggfunc = ggboxplot, add = c(\"jitter\"), \r\n  color = \"dose\", palette = \"npg\"\r\n  )<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/r-tutorial\/figures\/beautiful-plot-in-r-with-summary-statistics-labels-grouped-plots-1.png\" width=\"336\" \/><\/p>\n<\/div>\n<\/div>\n<div id=\"multipanel-plots-with-summary-table\" class=\"section level2\">\n<h2>Multipanel plots with summary table<\/h2>\n<p>Key arguments:<\/p>\n<ul>\n<li><code>facet.by<\/code>: character vector, of length 1 or 2, specifying grouping variables for faceting the plot into multiple panels. Should be in the data.<\/li>\n<li><code>labeller<\/code>: Character vector. Possible values are one of <code>label_both<\/code> (panel labelled by both grouping variable names and levels) and <code>label_value<\/code> (panel labelled with only grouping levels).<\/li>\n<\/ul>\n<p>Create panels according to one grouping variable:<\/p>\n<pre class=\"r\"><code>ggsummarystats(\r\n  df, x = \"dose\", y = \"len\", \r\n  ggfunc = ggboxplot, add = c(\"jitter\"), \r\n  color = \"dose\", palette = \"jco\",\r\n  facet.by = \"supp\", labeller = \"label_value\",\r\n  ggtheme = theme_bw(), legend = \"top\"\r\n)<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/r-tutorial\/figures\/beautiful-plot-in-r-with-summary-statistics-labels-multipanel-plots-with-summary-table-one-grouping-variable-1.png\" width=\"576\" \/><\/p>\n<p>Create panels according to two grouping variables<\/p>\n<pre class=\"r\"><code>ggsummarystats(\r\n  df, x = \"dose\", y = \"len\", \r\n  ggfunc = ggboxplot, add = c(\"jitter\"), \r\n  color = \"dose\", palette = \"jco\",\r\n  facet.by = c(\"supp\", \"qc\"), labeller = \"label_both\", \r\n  ggtheme = theme_bw(), legend = \"top\"\r\n)<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/r-tutorial\/figures\/beautiful-plot-in-r-with-summary-statistics-labels-multipanel-plots-with-summary-table-two-grouping-variables-1.png\" width=\"576\" \/><\/p>\n<p>Create independent panels using the argument <code>free<\/code>:<\/p>\n<pre class=\"r\"><code>ggsummarystats(\r\n  df, x = \"dose\", y = \"len\", \r\n  ggfunc = ggboxplot, add = c(\"jitter\"), \r\n  color = \"dose\", palette = \"jco\",\r\n  facet.by = c(\"supp\", \"qc\"), labeller = \"label_both\", \r\n  free.panels = TRUE,\r\n  ggtheme = theme_bw(), legend = \"top\"\r\n)<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/r-tutorial\/figures\/beautiful-plot-in-r-with-summary-statistics-labels-independent-panels-1.png\" width=\"576\" \/><\/p>\n<\/div>\n<div id=\"build-step-by-step-a-custom-multipanel-plot\" class=\"section level2\">\n<h2>Build step by step a custom multipanel plot<\/h2>\n<p>Create a multipanel box plot using one grouping variable (<code>supp<\/code>):<\/p>\n<pre class=\"r\"><code># Group the data by supp\r\n# Apply the function ggsummarystats to each subset\r\ndf.grouped &lt;- df %&gt;%\r\n  df_split_by(supp, label_col = \"panel\", labeller = df_label_both) %&gt;%\r\n  mutate(plot_list = map(\r\n    data, ggsummarystats, x = \"dose\", y = \"len\",\r\n    ggfunc = ggbarplot, \r\n    add = c(\"jitter\", \"median_iqr\"), \r\n    facet.by = \"panel\"\r\n    )\r\n  )\r\ndf.grouped<\/code><\/pre>\n<pre><code>## # A tibble: 2 x 4\r\n##   supp  data              panel   plot_list \r\n##   &lt;fct&gt; &lt;list&gt;            &lt;fct&gt;   &lt;list&gt;    \r\n## 1 VC    &lt;tibble [30 \u00d7 4]&gt; supp:OJ &lt;ggsmmrys&gt;\r\n## 2 OJ    &lt;tibble [30 \u00d7 4]&gt; supp:VC &lt;ggsmmrys&gt;<\/code><\/pre>\n<pre class=\"r\"><code># Print the plots\r\nplot_list &lt;- df.grouped$plot_list\r\nclass(plot_list) &lt;- c(\"ggsummarystats_list\", \"list\")\r\nprint(plot_list)<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/r-tutorial\/figures\/beautiful-plot-in-r-with-summary-statistics-labels-custom-multi-panel-bar-plots-1.png\" width=\"576\" \/><\/p>\n<\/div>\n<\/div>\n<p><!--end rdoc--><\/p>\n","protected":false},"excerpt":{"rendered":"<p>You will learn how to create beautiful plots in R and add summary summary statistics table such as sample size (n), median, mean and IQR onto the plot. We will [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":15585,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rating_form_position":"","rating_results_position":"","mr_structured_data_type":"","footnotes":""},"categories":[134],"tags":[343],"class_list":["post-15584","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-data-visualization","tag-ggpubr"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Create a Beautiful Plots in R with Summary Statistics Labels - 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\/blog\/how-to-create-a-beautiful-plots-in-r-with-summary-statistics-labels\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Create a Beautiful Plots in R with Summary Statistics Labels - Datanovia\" \/>\n<meta property=\"og:description\" content=\"You will learn how to create beautiful plots in R and add summary summary statistics table such as sample size (n), median, mean and IQR onto the plot. We will [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-plots-in-r-with-summary-statistics-labels\/\" \/>\n<meta property=\"og:site_name\" content=\"Datanovia\" \/>\n<meta property=\"article:published_time\" content=\"2020-04-01T21:12:12+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2020\/04\/beautiful-plot-in-r-with-summary-statistics-labels-boxplots-with-summary-statistics-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"960\" \/>\n\t<meta property=\"og:image:height\" content=\"768\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Alboukadel\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Alboukadel\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-plots-in-r-with-summary-statistics-labels\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-plots-in-r-with-summary-statistics-labels\/\"},\"author\":{\"name\":\"Alboukadel\",\"@id\":\"https:\/\/www.datanovia.com\/en\/#\/schema\/person\/7767cf2bd5c91a1610c6eb53a0ff069e\"},\"headline\":\"How to Create a Beautiful Plots in R with Summary Statistics Labels\",\"datePublished\":\"2020-04-01T21:12:12+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-plots-in-r-with-summary-statistics-labels\/\"},\"wordCount\":301,\"commentCount\":7,\"publisher\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-plots-in-r-with-summary-statistics-labels\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2020\/04\/beautiful-plot-in-r-with-summary-statistics-labels-boxplots-with-summary-statistics-1.png\",\"keywords\":[\"ggpubr\"],\"articleSection\":[\"Data Visualization\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-plots-in-r-with-summary-statistics-labels\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-plots-in-r-with-summary-statistics-labels\/\",\"url\":\"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-plots-in-r-with-summary-statistics-labels\/\",\"name\":\"How to Create a Beautiful Plots in R with Summary Statistics Labels - Datanovia\",\"isPartOf\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-plots-in-r-with-summary-statistics-labels\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-plots-in-r-with-summary-statistics-labels\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2020\/04\/beautiful-plot-in-r-with-summary-statistics-labels-boxplots-with-summary-statistics-1.png\",\"datePublished\":\"2020-04-01T21:12:12+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-plots-in-r-with-summary-statistics-labels\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-plots-in-r-with-summary-statistics-labels\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-plots-in-r-with-summary-statistics-labels\/#primaryimage\",\"url\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2020\/04\/beautiful-plot-in-r-with-summary-statistics-labels-boxplots-with-summary-statistics-1.png\",\"contentUrl\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2020\/04\/beautiful-plot-in-r-with-summary-statistics-labels-boxplots-with-summary-statistics-1.png\",\"width\":960,\"height\":768,\"caption\":\"beautiful-plot-in-r-with-summary-statistics-labels-boxplots-with-summary-statistics-1.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-plots-in-r-with-summary-statistics-labels\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.datanovia.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Create a Beautiful Plots in R with Summary Statistics Labels\"}]},{\"@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\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.datanovia.com\/en\/#\/schema\/person\/7767cf2bd5c91a1610c6eb53a0ff069e\",\"name\":\"Alboukadel\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.datanovia.com\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ed3108646c5c7c3d188324ab972f96ad7d9975b41b94014d7f68257791be395a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ed3108646c5c7c3d188324ab972f96ad7d9975b41b94014d7f68257791be395a?s=96&d=mm&r=g\",\"caption\":\"Alboukadel\"},\"url\":\"https:\/\/www.datanovia.com\/en\/blog\/author\/kassambara\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Create a Beautiful Plots in R with Summary Statistics Labels - 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\/blog\/how-to-create-a-beautiful-plots-in-r-with-summary-statistics-labels\/","og_locale":"en_US","og_type":"article","og_title":"How to Create a Beautiful Plots in R with Summary Statistics Labels - Datanovia","og_description":"You will learn how to create beautiful plots in R and add summary summary statistics table such as sample size (n), median, mean and IQR onto the plot. We will [&hellip;]","og_url":"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-plots-in-r-with-summary-statistics-labels\/","og_site_name":"Datanovia","article_published_time":"2020-04-01T21:12:12+00:00","og_image":[{"width":960,"height":768,"url":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2020\/04\/beautiful-plot-in-r-with-summary-statistics-labels-boxplots-with-summary-statistics-1.png","type":"image\/png"}],"author":"Alboukadel","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Alboukadel","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-plots-in-r-with-summary-statistics-labels\/#article","isPartOf":{"@id":"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-plots-in-r-with-summary-statistics-labels\/"},"author":{"name":"Alboukadel","@id":"https:\/\/www.datanovia.com\/en\/#\/schema\/person\/7767cf2bd5c91a1610c6eb53a0ff069e"},"headline":"How to Create a Beautiful Plots in R with Summary Statistics Labels","datePublished":"2020-04-01T21:12:12+00:00","mainEntityOfPage":{"@id":"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-plots-in-r-with-summary-statistics-labels\/"},"wordCount":301,"commentCount":7,"publisher":{"@id":"https:\/\/www.datanovia.com\/en\/#organization"},"image":{"@id":"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-plots-in-r-with-summary-statistics-labels\/#primaryimage"},"thumbnailUrl":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2020\/04\/beautiful-plot-in-r-with-summary-statistics-labels-boxplots-with-summary-statistics-1.png","keywords":["ggpubr"],"articleSection":["Data Visualization"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-plots-in-r-with-summary-statistics-labels\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-plots-in-r-with-summary-statistics-labels\/","url":"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-plots-in-r-with-summary-statistics-labels\/","name":"How to Create a Beautiful Plots in R with Summary Statistics Labels - Datanovia","isPartOf":{"@id":"https:\/\/www.datanovia.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-plots-in-r-with-summary-statistics-labels\/#primaryimage"},"image":{"@id":"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-plots-in-r-with-summary-statistics-labels\/#primaryimage"},"thumbnailUrl":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2020\/04\/beautiful-plot-in-r-with-summary-statistics-labels-boxplots-with-summary-statistics-1.png","datePublished":"2020-04-01T21:12:12+00:00","breadcrumb":{"@id":"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-plots-in-r-with-summary-statistics-labels\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-plots-in-r-with-summary-statistics-labels\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-plots-in-r-with-summary-statistics-labels\/#primaryimage","url":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2020\/04\/beautiful-plot-in-r-with-summary-statistics-labels-boxplots-with-summary-statistics-1.png","contentUrl":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2020\/04\/beautiful-plot-in-r-with-summary-statistics-labels-boxplots-with-summary-statistics-1.png","width":960,"height":768,"caption":"beautiful-plot-in-r-with-summary-statistics-labels-boxplots-with-summary-statistics-1.png"},{"@type":"BreadcrumbList","@id":"https:\/\/www.datanovia.com\/en\/blog\/how-to-create-a-beautiful-plots-in-r-with-summary-statistics-labels\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.datanovia.com\/en\/"},{"@type":"ListItem","position":2,"name":"How to Create a Beautiful Plots in R with Summary Statistics Labels"}]},{"@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\/"}},{"@type":"Person","@id":"https:\/\/www.datanovia.com\/en\/#\/schema\/person\/7767cf2bd5c91a1610c6eb53a0ff069e","name":"Alboukadel","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.datanovia.com\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/ed3108646c5c7c3d188324ab972f96ad7d9975b41b94014d7f68257791be395a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ed3108646c5c7c3d188324ab972f96ad7d9975b41b94014d7f68257791be395a?s=96&d=mm&r=g","caption":"Alboukadel"},"url":"https:\/\/www.datanovia.com\/en\/blog\/author\/kassambara\/"}]}},"multi-rating":{"mr_rating_results":[]},"_links":{"self":[{"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/posts\/15584","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/types\/post"}],"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=15584"}],"version-history":[{"count":1,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/posts\/15584\/revisions"}],"predecessor-version":[{"id":15587,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/posts\/15584\/revisions\/15587"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/media\/15585"}],"wp:attachment":[{"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/media?parent=15584"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/categories?post=15584"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/tags?post=15584"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}