{"id":8182,"date":"2018-11-13T08:31:06","date_gmt":"2018-11-13T06:31:06","guid":{"rendered":"https:\/\/www.datanovia.com\/en\/?p=8182"},"modified":"2019-12-25T11:19:07","modified_gmt":"2019-12-25T09:19:07","slug":"ggplot-theme-background-color-and-grids","status":"publish","type":"post","link":"https:\/\/www.datanovia.com\/en\/blog\/ggplot-theme-background-color-and-grids\/","title":{"rendered":"GGPlot Theme Background Color and Grids"},"content":{"rendered":"<div id=\"rdoc\">\n<p>This article shows how to change a <strong>ggplot theme background<\/strong> <em>color<\/em> and <em>grid<\/em> lines.<\/p>\n<p>The default theme of a ggplot2 graph has a grey background color. You can easily and quickly change this to a white background color by using the theme functions, such as <code>theme_bw()<\/code>, <code>theme_classic()<\/code>, <code>theme_minimal()<\/code> or <code>theme_light()<\/code> (See <a href=\"https:\/\/www.datanovia.com\/en\/blog\/ggplot-themes-gallery\/\">ggplot2 themes gallery<\/a>).<\/p>\n<p>Another alternative is to modify directly the arguments <code>panel.background<\/code> and <code>panel.grid<\/code> in the function <code>theme()<\/code>.<\/p>\n<p>In this R graphics tutorial, you will learn how to:<\/p>\n<ul>\n<li><strong>Change a ggplot background color<\/strong> using a custom color, say lightblue.<\/li>\n<li><strong>Remove the default ggplot grey background<\/strong> and replace it with a blank background color.<\/li>\n<li><strong>Remove panel border and background grid lines<\/strong> (minor and major grids).<\/li>\n<li><strong>Create<\/strong> and save a <strong>ggplot with transparent<\/strong> background (i.e., a ggplot with no background).<\/li>\n<li><strong>Create a ggplot with dark \/ black background color<\/strong>.<\/li>\n<\/ul>\n<p>Contents:<\/p>\n<div id=\"TOC\">\n<ul>\n<li><a href=\"#key-gglot2-r-functions\">Key gglot2 R functions<\/a><\/li>\n<li><a href=\"#create-a-basic-ggplot\">Create a basic ggplot<\/a><\/li>\n<li><a href=\"#change-background-color-and-grid-lines\">Change background color and grid lines<\/a><\/li>\n<li><a href=\"#remove-panel-border-and-background-grid-lines\">Remove panel border and background grid lines<\/a><\/li>\n<li><a href=\"#remove-grey-background-color\">Remove grey background color<\/a><\/li>\n<li><a href=\"#make-a-ggplot-with-transparent-background\">Make a ggplot with transparent background<\/a><\/li>\n<li><a href=\"#create-a-ggplot-with-black-background\">Create a ggplot with black background<\/a><\/li>\n<li><a href=\"#conclusion\">Conclusion<\/a><\/li>\n<\/ul>\n<\/div>\n<div id=\"key-gglot2-r-functions\" class=\"section level2\">\n<h2>Key gglot2 R functions<\/h2>\n<p>Key ggplot2 theme options to modify the plot panel and background:<\/p>\n<pre class=\"r\"><code>theme(\r\n  \r\n  plot.background = element_rect(),    # Background of the entire plot\r\n  \r\n  panel.background = element_rect(),   # Background of plotting area\r\n  panel.border = element_rect(),       # Border around plotting area.\r\n                                       # fill argument should be NA\r\n  \r\n  panel.grid = element_line(),         # All grid lines\r\n  panel.grid.major = element_line(),   # Major grid lines\r\n  panel.grid.minor = element_line(),   # Minor grid lines\r\n  \r\n  panel.grid.major.x = element_line(), # Vertical major grid lines\r\n  panel.grid.major.y = element_line(), # Horizontal major grid lines\r\n  panel.grid.minor.x = element_line(), # Vertical minor grid lines\r\n  panel.grid.minor.y = element_line()  # Vertical major grid lines\r\n)<\/code><\/pre>\n<p>Arguments of the helper functons:<\/p>\n<ul>\n<li><code>element_line(color, size, linetype)<\/code>. Modify grid lines color size and type.<\/li>\n<li><code>element_rect(fill, color, size, linetype)<\/code>. Modfify a rectangle element background fill, as well as, the border color, size and linetype.<\/li>\n<\/ul>\n<p>To remove a particular panel grid, use <code>element_blank()<\/code> for the corresponding theme argument. For example to remove the major grid lines for the x axis, use this: <code>p + theme(panel.grid.major.x = element_blank())<\/code>.<\/p>\n<\/div>\n<div id=\"create-a-basic-ggplot\" class=\"section level2\">\n<h2>Create a basic ggplot<\/h2>\n<pre class=\"r\"><code>library(ggplot2)\r\np &lt;- ggplot(ToothGrowth, aes(factor(dose), len)) +\r\n  geom_boxplot()\r\np<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/ggplot2\/figures\/028-ggplot-theme-background-color-and-grid-ggplot-example-1.png\" width=\"288\" \/><\/p>\n<\/div>\n<div id=\"change-background-color-and-grid-lines\" class=\"section level2\">\n<h2>Change background color and grid lines<\/h2>\n<ol style=\"list-style-type: decimal;\">\n<li>Change the panel background color<\/li>\n<li>Change the plot background color<\/li>\n<\/ol>\n<pre class=\"r\"><code># 1. Change plot panel background color to lightblue\r\n# and the color of major\/grid lines to white\r\np + theme(\r\n  panel.background = element_rect(fill = \"#BFD5E3\", colour = \"#6D9EC1\",\r\n                                size = 2, linetype = \"solid\"),\r\n  panel.grid.major = element_line(size = 0.5, linetype = 'solid',\r\n                                colour = \"white\"), \r\n  panel.grid.minor = element_line(size = 0.25, linetype = 'solid',\r\n                                colour = \"white\")\r\n  )\r\n\r\n# 2. Change the plot background color (not the panel)\r\np + theme(plot.background = element_rect(fill = \"#BFD5E3\"))<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/ggplot2\/figures\/028-ggplot-theme-background-color-and-grid-change-theme-background-colors-and-grid-lines-1.png\" width=\"288\" \/><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/ggplot2\/figures\/028-ggplot-theme-background-color-and-grid-change-theme-background-colors-and-grid-lines-2.png\" width=\"288\" \/><\/p>\n<\/div>\n<div id=\"remove-panel-border-and-background-grid-lines\" class=\"section level2\">\n<h2>Remove panel border and background grid lines<\/h2>\n<p>R function to hide plot panel borders and gridlines: <code>element_blank()<\/code>.<\/p>\n<pre class=\"r\"><code>p + theme(\r\n  # Hide panel borders and remove grid lines\r\n  panel.border = element_blank(),\r\n  panel.grid.major = element_blank(),\r\n  panel.grid.minor = element_blank(),\r\n  # Change axis line\r\n  axis.line = element_line(colour = \"black\")\r\n  )<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/ggplot2\/figures\/028-ggplot-theme-background-color-and-grid-remove-panel-border-and-no-grid-lines-1.png\" width=\"288\" \/><\/p>\n<\/div>\n<div id=\"remove-grey-background-color\" class=\"section level2\">\n<h2>Remove grey background color<\/h2>\n<ul>\n<li>Solution 1: Use the theme functions to get rid of the grey background (@ref(ggplot-themes-gallery).<\/li>\n<\/ul>\n<pre class=\"r\"><code>p + theme_bw()  # Black and white theme\r\n\r\np + theme_classic() # Classic theme<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/ggplot2\/figures\/028-ggplot-theme-background-color-and-grid-remove-grey-background-color-1.png\" width=\"288\" \/><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/ggplot2\/figures\/028-ggplot-theme-background-color-and-grid-remove-grey-background-color-2.png\" width=\"288\" \/><\/p>\n<ul>\n<li>Solution 2: Create, step-by-step, a ggplot with white background:<\/li>\n<\/ul>\n<pre class=\"r\"><code>p + theme(\r\n  # Remove panel border\r\n  panel.border = element_blank(),  \r\n  # Remove panel grid lines\r\n  panel.grid.major = element_blank(),\r\n  panel.grid.minor = element_blank(),\r\n  # Remove panel background\r\n  panel.background = element_blank(),\r\n  # Add axis line\r\n  axis.line = element_line(colour = \"grey\")\r\n  )<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/ggplot2\/figures\/028-ggplot-theme-background-color-and-grid-remove-gray-background-color-1.png\" width=\"288\" \/><\/p>\n<\/div>\n<div id=\"make-a-ggplot-with-transparent-background\" class=\"section level2\">\n<h2>Make a ggplot with transparent background<\/h2>\n<p>In this section you will learn how to make and save a ggplot with transparent background.<\/p>\n<ul>\n<li>Solution 1: Use the function <em>theme_transparent<\/em>() [in ggpubr package]. First, install it with <code>install.packages(\"ggpubr\")<\/code>, then type this:<\/li>\n<\/ul>\n<pre class=\"r\"><code>transparent.plot &lt;- p + ggpubr::theme_transparent()\r\nggsave(filename = \"transparent-background.png\",\r\n       plot = transparent.plot,\r\n       bg = \"transparent\", \r\n       width = 2, height = 1.5, units = \"in\")<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/ggplot2\/images\/transparent-background.png\" alt=\"Transparent background color\" \/><\/p>\n<ul>\n<li>Solution 2: Make a transparent background by starting from <code>theme_void()<\/code>:<\/li>\n<\/ul>\n<pre class=\"r\"><code>p + theme_void() + # Empty theme without axis lines and texts\r\n  theme(\r\n    panel.background = element_rect(fill = \"transparent\", colour = NA),\r\n    plot.background = element_rect(fill = \"transparent\", colour = NA),\r\n    legend.background = element_rect(fill = \"transparent\", colour = NA),\r\n    legend.box.background = element_rect(fill = \"transparent\", colour = NA)\r\n  )<\/code><\/pre>\n<\/div>\n<div id=\"create-a-ggplot-with-black-background\" class=\"section level2\">\n<h2>Create a ggplot with black background<\/h2>\n<p>Start by creating a simple scatter plot:<\/p>\n<pre class=\"r\"><code>sp &lt;- ggplot(iris, aes(Sepal.Length, Sepal.Width))+\r\n  geom_point(aes(color = Species, shape = Species))+\r\n  stat_smooth(aes(color = Species, fill = Species), \r\n              method = \"lm\", alpha = 0.2)+\r\n  scale_color_manual(values = c(\"#E4F00A\", \"white\", \"#22FF00\")) + \r\n  scale_fill_manual(values = c(\"#E4F00A\", \"white\", \"#22FF00\")) <\/code><\/pre>\n<p>Use the dark theme function - <code>theme_dark()<\/code>:<\/p>\n<pre class=\"r\"><code>sp + theme_dark() <\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/ggplot2\/figures\/028-ggplot-theme-background-color-and-grid-dark-theme-theme_dark-1.png\" width=\"480\" \/><\/p>\n<p>Create a ggplot with a black background:<\/p>\n<pre class=\"r\"><code>sp + theme(\r\n  # get rid of panel grids\r\n  panel.grid.major = element_blank(),\r\n  panel.grid.minor = element_blank(),\r\n  # Change plot and panel background\r\n  plot.background=element_rect(fill = \"gray\"),\r\n  panel.background = element_rect(fill = 'black'),\r\n  # Change legend \r\n  legend.position = c(0.6, 0.07),\r\n  legend.direction = \"horizontal\",\r\n  legend.background = element_rect(fill = \"black\", color = NA),\r\n  legend.key = element_rect(color = \"gray\", fill = \"black\"),\r\n  legend.title = element_text(color = \"white\"),\r\n  legend.text = element_text(color = \"white\")\r\n  )<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/ggplot2\/figures\/028-ggplot-theme-background-color-and-grid-black-background-1.png\" width=\"480\" \/><\/p>\n<\/div>\n<div id=\"conclusion\" class=\"section level2\">\n<h2>Conclusion<\/h2>\n<p>This article shows how to change a <strong>ggplot theme background<\/strong> <em>color<\/em> and <em>grid<\/em> lines. The essentials are summarized below:<\/p>\n<ul>\n<li>Create an example of ggplot:<\/li>\n<\/ul>\n<pre class=\"r\"><code>library(ggplot2)\r\np &lt;- ggplot(ToothGrowth, aes(factor(dose), len)) +\r\n  geom_boxplot()\r\np<\/code><\/pre>\n<ul>\n<li>Change ggplot background color:\n<ul>\n<li>use the standard ggplot2 themes (theme_classic(), theme_bw(), theme_minmal(), theme_light(), etc)<\/li>\n<li>or, edit the theme function as follow.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<pre class=\"r\"><code># Create a ggplot with white background\r\np + theme(\r\n  plot.background = element_rect(fill = \"white\"),\r\n  panel.background = element_rect(fill = \"white\"),\r\n  axis.line.x = element_line(color = \"grey\")\r\n  )<\/code><\/pre>\n<ul>\n<li>Create a ggplot with transparent background. The easiest solution is to use the theme_transparent() function [in ggpubr]<\/li>\n<\/ul>\n<pre class=\"r\"><code>p + ggpubr::theme_transparent()<\/code><\/pre>\n<\/div>\n<\/div>\n<p><!--end rdoc--><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article shows how to change a ggplot theme background color and grid lines. The default theme of a ggplot2 graph has a grey background color. You can easily and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":7915,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rating_form_position":"","rating_results_position":"","mr_structured_data_type":"","footnotes":""},"categories":[124],"tags":[315],"class_list":["post-8182","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ggplot2","tag-ggplot2-graphical-parameters"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Improve GGPlot Theme Background Color and Grids - Datanovia<\/title>\n<meta name=\"description\" content=\"You will learn how to change a ggplot theme background color and grid lines; remove the default grey background and panel border; create black background\" \/>\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\/ggplot-theme-background-color-and-grids\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Improve GGPlot Theme Background Color and Grids - Datanovia\" \/>\n<meta property=\"og:description\" content=\"You will learn how to change a ggplot theme background color and grid lines; remove the default grey background and panel border; create black background\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.datanovia.com\/en\/blog\/ggplot-theme-background-color-and-grids\/\" \/>\n<meta property=\"og:site_name\" content=\"Datanovia\" \/>\n<meta property=\"article:published_time\" content=\"2018-11-13T06:31:06+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-12-25T09:19:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/IMG_1266.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=\"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=\"5 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\/ggplot-theme-background-color-and-grids\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/ggplot-theme-background-color-and-grids\/\"},\"author\":{\"name\":\"Alboukadel\",\"@id\":\"https:\/\/www.datanovia.com\/en\/#\/schema\/person\/7767cf2bd5c91a1610c6eb53a0ff069e\"},\"headline\":\"GGPlot Theme Background Color and Grids\",\"datePublished\":\"2018-11-13T06:31:06+00:00\",\"dateModified\":\"2019-12-25T09:19:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/ggplot-theme-background-color-and-grids\/\"},\"wordCount\":446,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/ggplot-theme-background-color-and-grids\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/IMG_1266.jpg\",\"keywords\":[\"GGPLOT2 Graphical Parameters\"],\"articleSection\":[\"ggplot2\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.datanovia.com\/en\/blog\/ggplot-theme-background-color-and-grids\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/ggplot-theme-background-color-and-grids\/\",\"url\":\"https:\/\/www.datanovia.com\/en\/blog\/ggplot-theme-background-color-and-grids\/\",\"name\":\"How to Improve GGPlot Theme Background Color and Grids - Datanovia\",\"isPartOf\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/ggplot-theme-background-color-and-grids\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/ggplot-theme-background-color-and-grids\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/IMG_1266.jpg\",\"datePublished\":\"2018-11-13T06:31:06+00:00\",\"dateModified\":\"2019-12-25T09:19:07+00:00\",\"description\":\"You will learn how to change a ggplot theme background color and grid lines; remove the default grey background and panel border; create black background\",\"breadcrumb\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/ggplot-theme-background-color-and-grids\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.datanovia.com\/en\/blog\/ggplot-theme-background-color-and-grids\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/ggplot-theme-background-color-and-grids\/#primaryimage\",\"url\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/IMG_1266.jpg\",\"contentUrl\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/IMG_1266.jpg\",\"width\":1024,\"height\":512},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/ggplot-theme-background-color-and-grids\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.datanovia.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"GGPlot Theme Background Color and Grids\"}]},{\"@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 Improve GGPlot Theme Background Color and Grids - Datanovia","description":"You will learn how to change a ggplot theme background color and grid lines; remove the default grey background and panel border; create black background","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\/ggplot-theme-background-color-and-grids\/","og_locale":"en_US","og_type":"article","og_title":"How to Improve GGPlot Theme Background Color and Grids - Datanovia","og_description":"You will learn how to change a ggplot theme background color and grid lines; remove the default grey background and panel border; create black background","og_url":"https:\/\/www.datanovia.com\/en\/blog\/ggplot-theme-background-color-and-grids\/","og_site_name":"Datanovia","article_published_time":"2018-11-13T06:31:06+00:00","article_modified_time":"2019-12-25T09:19:07+00:00","og_image":[{"width":1024,"height":512,"url":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/IMG_1266.jpg","type":"image\/jpeg"}],"author":"Alboukadel","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Alboukadel","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.datanovia.com\/en\/blog\/ggplot-theme-background-color-and-grids\/#article","isPartOf":{"@id":"https:\/\/www.datanovia.com\/en\/blog\/ggplot-theme-background-color-and-grids\/"},"author":{"name":"Alboukadel","@id":"https:\/\/www.datanovia.com\/en\/#\/schema\/person\/7767cf2bd5c91a1610c6eb53a0ff069e"},"headline":"GGPlot Theme Background Color and Grids","datePublished":"2018-11-13T06:31:06+00:00","dateModified":"2019-12-25T09:19:07+00:00","mainEntityOfPage":{"@id":"https:\/\/www.datanovia.com\/en\/blog\/ggplot-theme-background-color-and-grids\/"},"wordCount":446,"commentCount":1,"publisher":{"@id":"https:\/\/www.datanovia.com\/en\/#organization"},"image":{"@id":"https:\/\/www.datanovia.com\/en\/blog\/ggplot-theme-background-color-and-grids\/#primaryimage"},"thumbnailUrl":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/IMG_1266.jpg","keywords":["GGPLOT2 Graphical Parameters"],"articleSection":["ggplot2"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.datanovia.com\/en\/blog\/ggplot-theme-background-color-and-grids\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.datanovia.com\/en\/blog\/ggplot-theme-background-color-and-grids\/","url":"https:\/\/www.datanovia.com\/en\/blog\/ggplot-theme-background-color-and-grids\/","name":"How to Improve GGPlot Theme Background Color and Grids - Datanovia","isPartOf":{"@id":"https:\/\/www.datanovia.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.datanovia.com\/en\/blog\/ggplot-theme-background-color-and-grids\/#primaryimage"},"image":{"@id":"https:\/\/www.datanovia.com\/en\/blog\/ggplot-theme-background-color-and-grids\/#primaryimage"},"thumbnailUrl":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/IMG_1266.jpg","datePublished":"2018-11-13T06:31:06+00:00","dateModified":"2019-12-25T09:19:07+00:00","description":"You will learn how to change a ggplot theme background color and grid lines; remove the default grey background and panel border; create black background","breadcrumb":{"@id":"https:\/\/www.datanovia.com\/en\/blog\/ggplot-theme-background-color-and-grids\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.datanovia.com\/en\/blog\/ggplot-theme-background-color-and-grids\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.datanovia.com\/en\/blog\/ggplot-theme-background-color-and-grids\/#primaryimage","url":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/IMG_1266.jpg","contentUrl":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/IMG_1266.jpg","width":1024,"height":512},{"@type":"BreadcrumbList","@id":"https:\/\/www.datanovia.com\/en\/blog\/ggplot-theme-background-color-and-grids\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.datanovia.com\/en\/"},{"@type":"ListItem","position":2,"name":"GGPlot Theme Background Color and Grids"}]},{"@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\/8182","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=8182"}],"version-history":[{"count":1,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/posts\/8182\/revisions"}],"predecessor-version":[{"id":8183,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/posts\/8182\/revisions\/8183"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/media\/7915"}],"wp:attachment":[{"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/media?parent=8182"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/categories?post=8182"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/tags?post=8182"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}