{"id":8313,"date":"2018-12-30T14:20:47","date_gmt":"2018-12-30T12:20:47","guid":{"rendered":"https:\/\/www.datanovia.com\/en\/?post_type=dt_lessons&#038;p=8313"},"modified":"2019-11-17T21:31:20","modified_gmt":"2019-11-17T19:31:20","slug":"ggplot-scatter-plot","status":"publish","type":"dt_lessons","link":"https:\/\/www.datanovia.com\/en\/lessons\/ggplot-scatter-plot\/","title":{"rendered":"GGPlot Scatter Plot"},"content":{"rendered":"<div id=\"rdoc\">\n<p>A <strong>Scatter plot<\/strong> (also known as <strong>X-Y plot<\/strong> or <strong>Point graph<\/strong>) is used to display the relationship between two continuous variables x and y.<\/p>\n<p>By displaying a variable in each axis, it is possible to determine if an association or a <em>correlation<\/em> exists between the two variables.<\/p>\n<p>The correlation can be: positive (values increase together), negative (one value decreases as the other increases), null (no correlation), linear, exponential and U-shaped.<\/p>\n<p>This article describes how to create scatter plots in R using the ggplot2 package.<\/p>\n<p>You will learn how to:<\/p>\n<ul>\n<li>Color points by groups<\/li>\n<li>Create bubble charts<\/li>\n<li>Add regression line to a scatter plot<\/li>\n<\/ul>\n<p>Contents:<\/p>\n<div id=\"TOC\">\n<ul>\n<li><a href=\"#data-preparation\">Data preparation<\/a><\/li>\n<li><a href=\"#loading-required-r-package\">Loading required R package<\/a><\/li>\n<li><a href=\"#basic-scatter-plots\">Basic scatter plots<\/a><\/li>\n<li><a href=\"#scatter-plots-with-multiple-groups\">Scatter plots with multiple groups<\/a><\/li>\n<li><a href=\"#add-regression-lines\">Add regression lines<\/a><\/li>\n<li><a href=\"#add-marginal-rugs-to-a-scatter-plot\">Add marginal rugs to a scatter plot<\/a><\/li>\n<li><a href=\"#jitter-points-to-reduce-overplotting\">Jitter points to reduce overplotting<\/a><\/li>\n<li><a href=\"#add-point-text-labels\">Add point text labels<\/a><\/li>\n<li><a href=\"#bubble-chart\">Bubble chart<\/a><\/li>\n<li><a href=\"#color-by-a-continuous-variable\">Color by a continuous variable<\/a><\/li>\n<\/ul>\n<\/div>\n<div class='dt-sc-hr-invisible-medium  '><\/div>\n<div class='dt-sc-ico-content type1'><div class='custom-icon' ><a href='https:\/\/www.datanovia.com\/en\/product\/ggplot2-essentials-for-great-data-visualization-in-r\/' target='_blank'><span class='fa fa-book'><\/span><\/a><\/div><h4><a href='https:\/\/www.datanovia.com\/en\/product\/ggplot2-essentials-for-great-data-visualization-in-r\/' target='_blank'> Related Book <\/a><\/h4>GGPlot2 Essentials for Great Data Visualization in R<\/div>\n<div class='dt-sc-hr-invisible-medium  '><\/div>\n<div id=\"data-preparation\" class=\"section level2\">\n<h2>Data preparation<\/h2>\n<p>Demo dataset: <code>mtcars<\/code>. The variable <code>cyl<\/code> is used as grouping variable.<\/p>\n<pre class=\"r\"><code># Load data\r\ndata(\"mtcars\")\r\ndf &lt;- mtcars\r\n\r\n# Convert cyl as a grouping variable\r\ndf$cyl &lt;- as.factor(df$cyl)\r\n\r\n# Inspect the data\r\nhead(df[, c(\"wt\", \"mpg\", \"cyl\", \"qsec\")], 4)<\/code><\/pre>\n<pre><code>##                  wt  mpg cyl qsec\r\n## Mazda RX4      2.62 21.0   6 16.5\r\n## Mazda RX4 Wag  2.88 21.0   6 17.0\r\n## Datsun 710     2.32 22.8   4 18.6\r\n## Hornet 4 Drive 3.21 21.4   6 19.4<\/code><\/pre>\n<\/div>\n<div id=\"loading-required-r-package\" class=\"section level2\">\n<h2>Loading required R package<\/h2>\n<p>Load the ggplot2 package and set the default theme to <code>theme_bw()<\/code> with the legend at the top of the plot:<\/p>\n<pre class=\"r\"><code>library(ggplot2)\r\ntheme_set(\r\n  theme_bw() +\r\n    theme(legend.position = \"top\")\r\n  )<\/code><\/pre>\n<\/div>\n<div id=\"basic-scatter-plots\" class=\"section level2\">\n<h2>Basic scatter plots<\/h2>\n<ul>\n<li>Key functions: <code>geom_point()<\/code> for creating scatter plots.<\/li>\n<li>Key arguments: <code>color<\/code>, <code>size<\/code> and <code>shape<\/code> to change point color, size and shape.<\/li>\n<\/ul>\n<pre class=\"r\"><code># Initiate a ggplot\r\nb &lt;- ggplot(df, aes(x = wt, y = mpg))\r\n\r\n# Basic scatter plot\r\nb + geom_point()\r\n     \r\n# Change color, shape and size\r\nb + geom_point(color = \"#00AFBB\", size = 2, shape = 23)<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/ggplot2\/figures\/004-ggplot-scatter-plot-geom_point-basic-scatter-plots-1.png\" width=\"240\" \/><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/ggplot2\/figures\/004-ggplot-scatter-plot-geom_point-basic-scatter-plots-2.png\" width=\"240\" \/><\/p>\n<p>The different point shapes commonly used in R, include:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/ggplot2\/figures\/004-ggplot-scatter-plot-point-shapes-1.png\" width=\"259.2\" \/><\/p>\n<\/div>\n<div id=\"scatter-plots-with-multiple-groups\" class=\"section level2\">\n<h2>Scatter plots with multiple groups<\/h2>\n<p>This section describes how to change point colors and shapes by groups. The functions <code>scale_color_manual()<\/code> and <code>scale_shape_manual()<\/code> are used to manually customize the color and the shape of points, respectively.<\/p>\n<p>In the R code below, point shapes and colors are controlled by the levels of the grouping variable <em>cyl<\/em> :<\/p>\n<pre class=\"r\"><code># Change point shapes by the levels of cyl\r\nb + geom_point(aes(shape = cyl))\r\n  \r\n# Change point shapes and colors by the levels of cyl\r\n# Set custom colors\r\nb + geom_point(aes(shape = cyl, color = cyl)) +\r\n  scale_color_manual(values = c(\"#00AFBB\", \"#E7B800\", \"#FC4E07\"))<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/ggplot2\/figures\/004-ggplot-scatter-plot-geom_point-scatter-plot-with-multiple-groups-1.png\" width=\"288\" \/><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/ggplot2\/figures\/004-ggplot-scatter-plot-geom_point-scatter-plot-with-multiple-groups-2.png\" width=\"288\" \/><\/p>\n<\/div>\n<div id=\"add-regression-lines\" class=\"section level2\">\n<h2>Add regression lines<\/h2>\n<ul>\n<li>Key R function: <code>geom_smooth()<\/code> for adding smoothed conditional means \/ regression line.<\/li>\n<li>Key arguments:\n<ul>\n<li><code>color<\/code>, <code>size<\/code> and <code>linetype<\/code>: Change the line color, size and type.<\/li>\n<li><code>fill<\/code>: Change the fill color of the confidence region.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>A simplified format of the function `geom_smooth():<\/p>\n<pre class=\"r\"><code>geom_smooth(method=\"auto\", se=TRUE, fullrange=FALSE, level=0.95)<\/code><\/pre>\n<div class=\"block\">\n<ul>\n<li><strong>method<\/strong> : smoothing method to be used. Possible values are lm, glm, gam, loess, rlm.\n<ul>\n<li><strong>method = \u201cloess\u201d<\/strong>: This is the default value for small number of observations. It computes a smooth local regression. You can read more about <strong>loess<\/strong> using the R code <strong>?loess<\/strong>.<\/li>\n<li><strong>method =\u201clm\u201d<\/strong>: It fits a <strong>linear model<\/strong>. Note that, it\u2019s also possible to indicate the formula as <strong>formula = y ~ poly(x, 3)<\/strong> to specify a degree 3 polynomial.<\/li>\n<\/ul>\n<\/li>\n<li><strong>se<\/strong> : logical value. If TRUE, confidence interval is displayed around smooth.<\/li>\n<li><strong>fullrange<\/strong> : logical value. If TRUE, the fit spans the full range of the plot<\/li>\n<li><strong>level<\/strong> : level of confidence interval to use. Default value is 0.95<\/li>\n<\/ul>\n<\/div>\n<p>To add a regression line on a scatter plot, the function <code>geom_smooth()<\/code> is used in combination with the argument <code>method = lm<\/code>. <code>lm<\/code> stands for linear model.<\/p>\n<pre class=\"r\"><code># Add regression line\r\nb + geom_point() + geom_smooth(method = lm)\r\n  \r\n# Point + regression line\r\n# Remove the confidence interval \r\nb + geom_point() + \r\n  geom_smooth(method = lm, se = FALSE)\r\n\r\n# loess method: local regression fitting\r\nb + geom_point() + geom_smooth()<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/ggplot2\/figures\/004-ggplot-scatter-plot-geom_smooth-scatter-plot-regression-lines-1.png\" width=\"211.2\" \/><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/ggplot2\/figures\/004-ggplot-scatter-plot-geom_smooth-scatter-plot-regression-lines-2.png\" width=\"211.2\" \/><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/ggplot2\/figures\/004-ggplot-scatter-plot-geom_smooth-scatter-plot-regression-lines-3.png\" width=\"211.2\" \/><\/p>\n<p><strong>Change point color and shapes by groups<\/strong>:<\/p>\n<pre class=\"r\"><code># Change color and shape by groups (cyl)\r\nb + geom_point(aes(color = cyl, shape=cyl)) + \r\n  geom_smooth(aes(color = cyl, fill = cyl), method = lm) +\r\n  scale_color_manual(values = c(\"#00AFBB\", \"#E7B800\", \"#FC4E07\"))+\r\n  scale_fill_manual(values = c(\"#00AFBB\", \"#E7B800\", \"#FC4E07\"))\r\n\r\n# Remove confidence intervals\r\n# Extend the regression lines: fullrange\r\nb + geom_point(aes(color = cyl, shape = cyl)) + \r\n  geom_smooth(aes(color = cyl), method = lm, se = FALSE, fullrange = TRUE) +\r\n    scale_color_manual(values = c(\"#00AFBB\", \"#E7B800\", \"#FC4E07\"))+\r\n  scale_fill_manual(values = c(\"#00AFBB\", \"#E7B800\", \"#FC4E07\"))<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/ggplot2\/figures\/004-ggplot-scatter-plot-geom_smooth-change-point-shape-and-color-by-groups-1.png\" width=\"316.8\" \/><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/ggplot2\/figures\/004-ggplot-scatter-plot-geom_smooth-change-point-shape-and-color-by-groups-2.png\" width=\"316.8\" \/><\/p>\n<\/div>\n<div id=\"add-marginal-rugs-to-a-scatter-plot\" class=\"section level2\">\n<h2>Add marginal rugs to a scatter plot<\/h2>\n<p>The function <code>geom_rug()<\/code> is used to display display individual cases on the plot.<\/p>\n<pre class=\"r\"><code># Add marginal rugs\r\nb + geom_point() + geom_rug()\r\n\r\n# Change colors by groups\r\nb + geom_point(aes(color = cyl)) + \r\n  geom_rug(aes(color = cyl))\r\n\r\n# Add marginal rugs using faithful data\r\ndata(faithful)\r\nggplot(faithful, aes(x = eruptions, y = waiting)) +\r\n  geom_point() + geom_rug()<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/ggplot2\/figures\/004-ggplot-scatter-plot-geom_rug-scatter-plot-with-marginal-rugs-1.png\" width=\"211.2\" \/><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/ggplot2\/figures\/004-ggplot-scatter-plot-geom_rug-scatter-plot-with-marginal-rugs-2.png\" width=\"211.2\" \/><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/ggplot2\/figures\/004-ggplot-scatter-plot-geom_rug-scatter-plot-with-marginal-rugs-3.png\" width=\"211.2\" \/><\/p>\n<\/div>\n<div id=\"jitter-points-to-reduce-overplotting\" class=\"section level2\">\n<h2>Jitter points to reduce overplotting<\/h2>\n<p>The <code>mpg<\/code> data set [in <strong>ggplot2<\/strong>] is used in the following examples.<\/p>\n<p>To reduce overplotting, the option <code>position = position_jitter()<\/code> with the arguments <em>width<\/em> and <em>height<\/em> are used:<\/p>\n<ul>\n<li><em>width<\/em>: degree of jitter in x direction.<\/li>\n<li><em>height<\/em>: degree of jitter in y direction.<\/li>\n<\/ul>\n<pre class=\"r\"><code># Default plot\r\nggplot(mpg, aes(displ, hwy)) +\r\n  geom_point()\r\n\r\n# Use jitter to reduce overplotting\r\nggplot(mpg, aes(displ, hwy)) +\r\n  geom_point(position = position_jitter(width = 0.5, height = 0.5))<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/ggplot2\/figures\/004-ggplot-scatter-plot-scatter-plot-geom_jitter-1.png\" width=\"288\" \/><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/ggplot2\/figures\/004-ggplot-scatter-plot-scatter-plot-geom_jitter-2.png\" width=\"288\" \/><\/p>\n<\/div>\n<div id=\"add-point-text-labels\" class=\"section level2\">\n<h2>Add point text labels<\/h2>\n<p>Key functions:<\/p>\n<ul>\n<li><code>geom_text()<\/code> and <code>geom_label()<\/code>: ggplot2 standard functions to add text to a plot.<\/li>\n<li><code>geom_text_repel()<\/code> and <code>geom_label_repel()<\/code> [in ggrepel package]. Repulsive textual annotations. Avoid text overlapping.<\/li>\n<\/ul>\n<p>First install <code>ggrepel<\/code> (<code>\u00ecnstall.packages(\"ggrepel\")<\/code>), then type this:<\/p>\n<pre class=\"r\"><code>library(ggrepel)\r\n\r\n# Add text to the plot\r\n.labs &lt;- rownames(df)\r\nb + geom_point(aes(color = cyl)) +\r\n  geom_text_repel(aes(label = .labs,  color = cyl), size = 3)+\r\n  scale_color_manual(values = c(\"#00AFBB\", \"#E7B800\", \"#FC4E07\"))<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/ggplot2\/figures\/004-ggplot-scatter-plot-scatter-plot-with-point-text-1.png\" width=\"576\" \/><\/p>\n<pre class=\"r\"><code># Draw a rectangle underneath the text, making it easier to read.\r\nb + geom_point(aes(color = cyl)) +\r\n  geom_label_repel(aes(label = .labs,  color = cyl), size = 3)+\r\n  scale_color_manual(values = c(\"#00AFBB\", \"#E7B800\", \"#FC4E07\"))<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/ggplot2\/figures\/004-ggplot-scatter-plot-scatter-plot-with-point-text-2.png\" width=\"576\" \/><\/p>\n<\/div>\n<div id=\"bubble-chart\" class=\"section level2\">\n<h2>Bubble chart<\/h2>\n<p>In a bubble chart, points <code>size<\/code> is controlled by a continuous variable, here <code>qsec<\/code>. In the R code below, the argument alpha is used to control color transparency. alpha should be between 0 and 1.<\/p>\n<pre class=\"r\"><code>b + geom_point(aes(color = cyl, size = qsec), alpha = 0.5) +\r\n  scale_color_manual(values = c(\"#00AFBB\", \"#E7B800\", \"#FC4E07\")) +\r\n  scale_size(range = c(0.5, 12))  # Adjust the range of points size<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/ggplot2\/figures\/004-ggplot-scatter-plot-bubble-chart-1.png\" width=\"480\" \/><\/p>\n<\/div>\n<div id=\"color-by-a-continuous-variable\" class=\"section level2\">\n<h2>Color by a continuous variable<\/h2>\n<ul>\n<li>Color points according to the values of the continuous variable: \u201cmpg\u201d.<\/li>\n<li>Change the default blue gradient color using the function <code>scale_color_gradientn()<\/code> [in ggplot2], by specifying two or more colors.<\/li>\n<\/ul>\n<pre class=\"r\"><code>b + geom_point(aes(color = mpg), size = 3) +\r\n  scale_color_gradientn(colors = c(\"#00AFBB\", \"#E7B800\", \"#FC4E07\")) +\r\n  theme(legend.position = \"right\")<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/ggplot2\/figures\/004-ggplot-scatter-plot-color-by-continuous-variable-1.png\" width=\"384\" \/><\/p>\n<\/div>\n<\/div>\n<p><!--end rdoc--><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A Scatter plot is used to display the relationship between two continuous variables x and y. This article describes how to create scatter plots in R using the ggplot2 package. You will learn how to: 1) Color points by groups; 2) Create bubble charts; 3) Add regression line to a scatter plot.<\/p>\n","protected":false},"author":1,"featured_media":7915,"parent":0,"menu_order":2,"comment_status":"open","ping_status":"closed","template":"","class_list":["post-8313","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>GGPlot Scatter Plot Best Reference - Datanovia<\/title>\n<meta name=\"description\" content=\"This article describes how to create scatter plots in R using the ggplot2 package. You will learn how to: 1) Color points by groups; 2) Create bubble charts; 3) Add regression line to a scatter plot\" \/>\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\/ggplot-scatter-plot\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"GGPlot Scatter Plot Best Reference - Datanovia\" \/>\n<meta property=\"og:description\" content=\"This article describes how to create scatter plots in R using the ggplot2 package. You will learn how to: 1) Color points by groups; 2) Create bubble charts; 3) Add regression line to a scatter plot\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.datanovia.com\/en\/lessons\/ggplot-scatter-plot\/\" \/>\n<meta property=\"og:site_name\" content=\"Datanovia\" \/>\n<meta property=\"article:modified_time\" content=\"2019-11-17T19:31:20+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=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.datanovia.com\/en\/lessons\/ggplot-scatter-plot\/\",\"url\":\"https:\/\/www.datanovia.com\/en\/lessons\/ggplot-scatter-plot\/\",\"name\":\"GGPlot Scatter Plot Best Reference - Datanovia\",\"isPartOf\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/lessons\/ggplot-scatter-plot\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/lessons\/ggplot-scatter-plot\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/IMG_1266.jpg\",\"datePublished\":\"2018-12-30T12:20:47+00:00\",\"dateModified\":\"2019-11-17T19:31:20+00:00\",\"description\":\"This article describes how to create scatter plots in R using the ggplot2 package. You will learn how to: 1) Color points by groups; 2) Create bubble charts; 3) Add regression line to a scatter plot\",\"breadcrumb\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/lessons\/ggplot-scatter-plot\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.datanovia.com\/en\/lessons\/ggplot-scatter-plot\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.datanovia.com\/en\/lessons\/ggplot-scatter-plot\/#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\/lessons\/ggplot-scatter-plot\/#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\":\"GGPlot Scatter Plot\"}]},{\"@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":"GGPlot Scatter Plot Best Reference - Datanovia","description":"This article describes how to create scatter plots in R using the ggplot2 package. You will learn how to: 1) Color points by groups; 2) Create bubble charts; 3) Add regression line to a scatter plot","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\/ggplot-scatter-plot\/","og_locale":"en_US","og_type":"article","og_title":"GGPlot Scatter Plot Best Reference - Datanovia","og_description":"This article describes how to create scatter plots in R using the ggplot2 package. You will learn how to: 1) Color points by groups; 2) Create bubble charts; 3) Add regression line to a scatter plot","og_url":"https:\/\/www.datanovia.com\/en\/lessons\/ggplot-scatter-plot\/","og_site_name":"Datanovia","article_modified_time":"2019-11-17T19:31:20+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"}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.datanovia.com\/en\/lessons\/ggplot-scatter-plot\/","url":"https:\/\/www.datanovia.com\/en\/lessons\/ggplot-scatter-plot\/","name":"GGPlot Scatter Plot Best Reference - Datanovia","isPartOf":{"@id":"https:\/\/www.datanovia.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.datanovia.com\/en\/lessons\/ggplot-scatter-plot\/#primaryimage"},"image":{"@id":"https:\/\/www.datanovia.com\/en\/lessons\/ggplot-scatter-plot\/#primaryimage"},"thumbnailUrl":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/IMG_1266.jpg","datePublished":"2018-12-30T12:20:47+00:00","dateModified":"2019-11-17T19:31:20+00:00","description":"This article describes how to create scatter plots in R using the ggplot2 package. You will learn how to: 1) Color points by groups; 2) Create bubble charts; 3) Add regression line to a scatter plot","breadcrumb":{"@id":"https:\/\/www.datanovia.com\/en\/lessons\/ggplot-scatter-plot\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.datanovia.com\/en\/lessons\/ggplot-scatter-plot\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.datanovia.com\/en\/lessons\/ggplot-scatter-plot\/#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\/lessons\/ggplot-scatter-plot\/#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":"GGPlot Scatter Plot"}]},{"@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\/8313","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=8313"}],"version-history":[{"count":1,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/dt_lessons\/8313\/revisions"}],"predecessor-version":[{"id":10462,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/dt_lessons\/8313\/revisions\/10462"}],"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=8313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}