Skip to content

Commit

Permalink
upload ch1 images
Browse files Browse the repository at this point in the history
  • Loading branch information
vzrg-tamu committed Jan 16, 2024
1 parent f20e154 commit 5e239e2
Show file tree
Hide file tree
Showing 29 changed files with 20 additions and 19 deletions.
1 change: 1 addition & 0 deletions _quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ book:
format:
html:
theme: yeti
rmdformats::readthedown:
code-fold: false
self_contained: true
thumbnails: false
Expand Down
Binary file modified awesome_plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 17 additions & 17 deletions docs/data.html
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ <h2 data-number="2.1" class="anchored" data-anchor-id="basic-operators"><span cl
<hr>
<p>In this section, we will learn about some basic R operators that are used to perform operations on values and variables. Some most commonly used operators are shown in the table below.</p>
<center>
<img src="C:/Users/VSehgal/OneDrive%20-%20LSU%20AgCenter/TAMU/Teaching/DataVisWorkshop/DataVisWorkshop2020/SampleData-master/images/Basic_operators.png" class="img-fluid" style="width:70.0%">
<img src="C:/Users/VSehgal/OneDrive%20-%20LSU%20AgCenter/LSU/02_Teaching/AGRO%204092/AGRO4092/images/Basic_operators.png" class="img-fluid" style="width:70.0%">
</center>
<div class="cell">
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="dv">2</span><span class="sc">+</span><span class="dv">4</span><span class="sc">+</span><span class="dv">7</span> <span class="co"># Sum </span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
Expand Down Expand Up @@ -409,7 +409,7 @@ <h2 data-number="2.2" class="anchored" data-anchor-id="basic-data-operations"><s
<h2 data-number="2.3" class="anchored" data-anchor-id="data-types"><span class="header-section-number">2.3</span> 1.3. Data types</h2>
<p>In R, data is stored as an “array”, which can be 1-dimensional or 2-dimensional. A 1-D array is called a “vector” and a 2-D array is a “matrix”. A table in R is called a “data frame” and a “list” is a container to hold a variety of data types. In this section, we will learn how to create matrices, lists and data frames in R.</p>
<center>
<img src="C:/Users/VSehgal/OneDrive%20-%20LSU%20AgCenter/TAMU/Teaching/DataVisWorkshop/DataVisWorkshop2020/SampleData-master/images/list_visual.png" class="img-fluid" style="width:80.0%">
<img src="C:/Users/VSehgal/OneDrive%20-%20LSU%20AgCenter/LSU/02_Teaching/AGRO%204092/AGRO4092/images/list_visual.png" class="img-fluid" style="width:80.0%">
</center>
<div class="cell">
<div class="sourceCode cell-code" id="cb68"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb68-1"><a href="#cb68-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Lets make a random matrix</span></span>
Expand Down Expand Up @@ -463,13 +463,13 @@ <h2 data-number="2.3" class="anchored" data-anchor-id="data-types"><span class="
<span id="cb80-8"><a href="#cb80-8" aria-hidden="true" tabindex="-1"></a>out[[<span class="dv">2</span>]] <span class="ot">=</span> data2</span>
<span id="cb80-9"><a href="#cb80-9" aria-hidden="true" tabindex="-1"></a>out[[<span class="dv">1</span>]] <span class="co"># Contains data1 at this location</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code> [1] 26.41363 21.32451 22.19748 23.77007 24.88129 29.36403 20.45459 27.92240
[9] 29.15744 20.54412 26.97326 20.69808 26.64123 25.78460 22.86230 29.99233
[17] 25.92558 23.92407 23.43130 25.40376 21.56601 20.01961 27.14761 26.85204
[25] 26.20645 23.10430 20.55348 24.87707 27.09192 23.27355 29.59677 27.81175
[33] 20.27653 28.39099 27.71647 20.75456 29.16680 20.67626 22.26686 25.25857
[41] 21.36531 23.70305 22.53641 29.99708 21.61258 23.50977 23.68980 29.66676
[49] 29.05393 21.88943</code></pre>
<pre><code> [1] 28.67726 25.03160 27.86445 20.98036 24.60530 27.37740 28.29206 27.40080
[9] 28.94446 25.41546 26.06877 27.64949 25.43673 27.32287 22.85244 22.34016
[17] 27.10802 24.28308 25.17288 26.37545 21.65051 29.28946 22.18756 28.73152
[25] 25.71382 24.33592 29.77967 23.55662 29.37977 25.30416 20.24493 20.80997
[33] 21.12646 23.22161 29.22977 23.78019 23.63356 20.26902 24.92533 23.60659
[41] 26.81600 23.99879 24.83909 20.60728 21.39296 20.47559 23.29264 21.31763
[49] 29.55323 21.27144</code></pre>
</div>
<div class="sourceCode cell-code" id="cb82"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb82-1"><a href="#cb82-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Data frame</span></span>
<span id="cb82-2"><a href="#cb82-2" aria-hidden="true" tabindex="-1"></a>out<span class="ot">=</span><span class="fu">data.frame</span>(<span class="at">x=</span>data1, <span class="at">y=</span>data2)</span>
Expand Down Expand Up @@ -801,14 +801,14 @@ <h2 data-number="4.3" class="anchored" data-anchor-id="multivariate-plots"><span
<span id="cb110-14"><a href="#cb110-14" aria-hidden="true" tabindex="-1"></a><span class="fu">head</span>(dat2) <span class="co"># The data is now shaped in the long format</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code># A tibble: 6 × 4
Year January Month Value
&lt;dbl&gt; &lt;dbl&gt; &lt;chr&gt; &lt;dbl&gt;
1 1913 45.7 Jan -3.69
2 1913 45.7 Feb -10.7
3 1913 45.7 Mar -10.3
4 1914 1.96 Jan -10.4
5 1914 1.96 Feb -3.75
6 1914 1.96 Mar -9.17</code></pre>
Year January Month Value
&lt;dbl&gt; &lt;dbl&gt; &lt;chr&gt; &lt;dbl&gt;
1 1913 85.0 Jan -5.09
2 1913 85.0 Feb -5.55
3 1913 85.0 Mar -9.18
4 1914 39.2 Jan -3.99
5 1914 39.2 Feb -7.88
6 1914 39.2 Mar -5.31</code></pre>
</div>
</div>
<p><strong>Line plot</strong></p>
Expand Down
Binary file modified docs/data_files/figure-html/Data types-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/data_files/figure-html/Data types-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/data_files/figure-html/Multivariate data frame-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/data_files/figure-html/Multivariate data frame-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/data_files/figure-html/Multivariate data frame-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/data_files/figure-html/Multivariate data frame-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/data_files/figure-html/Univariate data-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/data_files/figure-html/Univariate data-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/data_files/figure-html/data frame and list-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/data_files/figure-html/data frame and list-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/data_files/figure-html/data frame and list-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/data_files/figure-html/data frame and list-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/data_files/figure-html/data frame and list-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/data_files/figure-html/data frame and list-6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/data_files/figure-html/density plot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/data_files/figure-html/grid plotting and saving 1-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/data_files/figure-html/histogram-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/data_files/figure-html/line plot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/data_files/figure-html/load packages and data for plots-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/data_files/figure-html/load packages and data for plots-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/data_files/figure-html/time series-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/data_files/figure-html/using layout-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/data_files/figure-html/using layout-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/search.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"href": "data.html#data-types",
"title": "2  Operators and data types",
"section": "2.3 1.3. Data types",
"text": "2.3 1.3. Data types\nIn R, data is stored as an “array”, which can be 1-dimensional or 2-dimensional. A 1-D array is called a “vector” and a 2-D array is a “matrix”. A table in R is called a “data frame” and a “list” is a container to hold a variety of data types. In this section, we will learn how to create matrices, lists and data frames in R.\n\n\n\n\n# Lets make a random matrix\ntest_mat = matrix( c(2, 4, 3, 1, 5, 7), # The data elements \n nrow=2, # Number of rows \n ncol=3, # Number of columns \n byrow = TRUE) # Fill matrix by rows \n\ntest_mat = matrix( c(2, 4, 3, 1, 5, 7),nrow=2,ncol=3,byrow = TRUE) # Same result \ntest_mat\n\n [,1] [,2] [,3]\n[1,] 2 4 3\n[2,] 1 5 7\n\ntest_mat[,2] # Display all rows, and second column\n\n[1] 4 5\n\ntest_mat[2,] # Display second row, all columns\n\n[1] 1 5 7\n\n# Types of datasets\nout = as.matrix(test_mat)\nout # This is a matrix\n\n [,1] [,2] [,3]\n[1,] 2 4 3\n[2,] 1 5 7\n\nout = as.array(test_mat)\nout # This is also a matrix\n\n [,1] [,2] [,3]\n[1,] 2 4 3\n[2,] 1 5 7\n\nout = as.vector(test_mat)\nout # This is just a vector\n\n[1] 2 1 4 5 3 7\n\n# Data frame and list\ndata1=runif(50,20,30) # Create 50 random numbers between 20 and 30 \ndata2=runif(50,0,10) # Create 50 random numbers between 0 and 10 \n\n# Lists\nout = list() # Create and empty list\nout[[1]] = data1 # Notice the brackets \"[[ ]]\" instead of \"[ ]\"\nout[[2]] = data2\nout[[1]] # Contains data1 at this location\n\n [1] 26.41363 21.32451 22.19748 23.77007 24.88129 29.36403 20.45459 27.92240\n [9] 29.15744 20.54412 26.97326 20.69808 26.64123 25.78460 22.86230 29.99233\n[17] 25.92558 23.92407 23.43130 25.40376 21.56601 20.01961 27.14761 26.85204\n[25] 26.20645 23.10430 20.55348 24.87707 27.09192 23.27355 29.59677 27.81175\n[33] 20.27653 28.39099 27.71647 20.75456 29.16680 20.67626 22.26686 25.25857\n[41] 21.36531 23.70305 22.53641 29.99708 21.61258 23.50977 23.68980 29.66676\n[49] 29.05393 21.88943\n\n# Data frame\nout=data.frame(x=data1, y=data2)\n\n# Let's see how it looks!\nplot(out$x, out$y)\n\n\n\nplot(out[,1])"
"text": "2.3 1.3. Data types\nIn R, data is stored as an “array”, which can be 1-dimensional or 2-dimensional. A 1-D array is called a “vector” and a 2-D array is a “matrix”. A table in R is called a “data frame” and a “list” is a container to hold a variety of data types. In this section, we will learn how to create matrices, lists and data frames in R.\n\n\n\n\n# Lets make a random matrix\ntest_mat = matrix( c(2, 4, 3, 1, 5, 7), # The data elements \n nrow=2, # Number of rows \n ncol=3, # Number of columns \n byrow = TRUE) # Fill matrix by rows \n\ntest_mat = matrix( c(2, 4, 3, 1, 5, 7),nrow=2,ncol=3,byrow = TRUE) # Same result \ntest_mat\n\n [,1] [,2] [,3]\n[1,] 2 4 3\n[2,] 1 5 7\n\ntest_mat[,2] # Display all rows, and second column\n\n[1] 4 5\n\ntest_mat[2,] # Display second row, all columns\n\n[1] 1 5 7\n\n# Types of datasets\nout = as.matrix(test_mat)\nout # This is a matrix\n\n [,1] [,2] [,3]\n[1,] 2 4 3\n[2,] 1 5 7\n\nout = as.array(test_mat)\nout # This is also a matrix\n\n [,1] [,2] [,3]\n[1,] 2 4 3\n[2,] 1 5 7\n\nout = as.vector(test_mat)\nout # This is just a vector\n\n[1] 2 1 4 5 3 7\n\n# Data frame and list\ndata1=runif(50,20,30) # Create 50 random numbers between 20 and 30 \ndata2=runif(50,0,10) # Create 50 random numbers between 0 and 10 \n\n# Lists\nout = list() # Create and empty list\nout[[1]] = data1 # Notice the brackets \"[[ ]]\" instead of \"[ ]\"\nout[[2]] = data2\nout[[1]] # Contains data1 at this location\n\n [1] 28.67726 25.03160 27.86445 20.98036 24.60530 27.37740 28.29206 27.40080\n [9] 28.94446 25.41546 26.06877 27.64949 25.43673 27.32287 22.85244 22.34016\n[17] 27.10802 24.28308 25.17288 26.37545 21.65051 29.28946 22.18756 28.73152\n[25] 25.71382 24.33592 29.77967 23.55662 29.37977 25.30416 20.24493 20.80997\n[33] 21.12646 23.22161 29.22977 23.78019 23.63356 20.26902 24.92533 23.60659\n[41] 26.81600 23.99879 24.83909 20.60728 21.39296 20.47559 23.29264 21.31763\n[49] 29.55323 21.27144\n\n# Data frame\nout=data.frame(x=data1, y=data2)\n\n# Let's see how it looks!\nplot(out$x, out$y)\n\n\n\nplot(out[,1])"
},
{
"objectID": "data.html#overview",
Expand Down Expand Up @@ -95,6 +95,6 @@
"href": "data.html#multivariate-plots",
"title": "2  Operators and data types",
"section": "4.3 3.3. Multivariate plots",
"text": "4.3 3.3. Multivariate plots\nFor multivariate data, ggplot takes the data in the form of groups. This means that each data row should be identifiable to a group. To get the most out of ggplot, we will need to reshape our dataset.\n\nlibrary(tidyr)\n\n# There are two generally data formats: wide (horizontal) and long (vertical). In the horizontal format, every column represents a category of the data. In the vertical format, every row represents an observation for a particular category (think of each row as a data point). Both formats have their comparative advantages. We will now convert the data frame we randomly generated in the previous section to the long format. Here are several ways to do this:\n\n# Using the gather function\ndat2 = dat %&gt;% gather(Month, Value, -Year)\n\n# Using pivot_longer and selecting all of the columns we want. This function is the best!\ndat2 = dat %&gt;% pivot_longer(cols = c(Jan, Feb, Mar), names_to = \"Month\", values_to = \"Value\") \n\n# Or we can choose to exclude the columns we don't want\ndat2 = dat %&gt;% pivot_longer(cols = -c(Year,January), names_to = \"Month\", values_to = \"Value\") \n\nhead(dat2) # The data is now shaped in the long format\n\n# A tibble: 6 × 4\n Year January Month Value\n &lt;dbl&gt; &lt;dbl&gt; &lt;chr&gt; &lt;dbl&gt;\n1 1913 45.7 Jan -3.69\n2 1913 45.7 Feb -10.7 \n3 1913 45.7 Mar -10.3 \n4 1914 1.96 Jan -10.4 \n5 1914 1.96 Feb -3.75\n6 1914 1.96 Mar -9.17\n\n\nLine plot\n\n# LINE PLOT\nl = ggplot(dat2, aes(x = Year, y = Value, group = Month)) +\n geom_line(aes(color = Month)) +\n geom_point(aes(color = Month))\nl\n\n\n\n\nDensity plot\n\n# DENSITY PLOT\nd = ggplot(dat2, aes(x = Value))\nd = d + geom_density(aes(color = Month, fill = Month), alpha=0.4) # Alpha specifies transparency\nd\n\n\n\n\nHistogram\n\n# HISTOGRAM\nh = ggplot(dat2, aes(x = Value))\nh = h + geom_histogram(aes(color = Month, fill = Month), alpha=0.4,\n fill = \"white\",\n position = \"dodge\")\nh\n\n\n\n\nGrid plotting and saving files to disk\nThere are multiple ways to arrange multiple plots and save images. One method is using grid.arrange() which is found in the gridExtra package. You can then save the file using ggsave, which comes with the ggplot2 library.\n\n# The plots can be displayed together on one image using \n# grid.arrange from the gridExtra package\nimg = grid.arrange(l, d, h, nrow=3)\n\n\n\n# Finally, plots created using ggplot can be saved using ggsave\nggsave(\"grid_plot_1.png\", \n plot = img, \n device = \"png\", \n width = 6, \n height = 4, \n units = c(\"in\"), \n dpi = 600)\n\nAnother approach is to use the plot_grid function, which is in the cowplot library. Notice how the axes are now beautifally aligned.\n\nimg2=cowplot::plot_grid(l, d, h, nrow = 3, align = \"v\") # \"v\" aligns vertical axes and \"h\" aligns horizontal axes\n\nggsave(\"grid_plot_2.png\", \n plot = img2, \n device = \"png\", \n width = 6, \n height = 4, \n units = c(\"in\"), \n dpi = 600)\n\n Some useful resources\nThe links below offer a treasure trove of examples and sample code to get you started.\nThe R Graph Gallery: https://www.r-graph-gallery.com/\nLine plots in ggplot2: http://www.sthda.com/english/wiki/ggplot2-line-plot-quick-start-guide-r-software-and-data-visualization\nTop 50 visualizations with ggplot2: http://r-statistics.co/Top50-Ggplot2-Visualizations-MasterList-R-Code.html\nPractical guide in ggplot2: http://www.sthda.com/english/wiki/be-awesome-in-ggplot2-a-practical-guide-to-be-highly-effective-r-software-and-data-visualization"
"text": "4.3 3.3. Multivariate plots\nFor multivariate data, ggplot takes the data in the form of groups. This means that each data row should be identifiable to a group. To get the most out of ggplot, we will need to reshape our dataset.\n\nlibrary(tidyr)\n\n# There are two generally data formats: wide (horizontal) and long (vertical). In the horizontal format, every column represents a category of the data. In the vertical format, every row represents an observation for a particular category (think of each row as a data point). Both formats have their comparative advantages. We will now convert the data frame we randomly generated in the previous section to the long format. Here are several ways to do this:\n\n# Using the gather function\ndat2 = dat %&gt;% gather(Month, Value, -Year)\n\n# Using pivot_longer and selecting all of the columns we want. This function is the best!\ndat2 = dat %&gt;% pivot_longer(cols = c(Jan, Feb, Mar), names_to = \"Month\", values_to = \"Value\") \n\n# Or we can choose to exclude the columns we don't want\ndat2 = dat %&gt;% pivot_longer(cols = -c(Year,January), names_to = \"Month\", values_to = \"Value\") \n\nhead(dat2) # The data is now shaped in the long format\n\n# A tibble: 6 × 4\n Year January Month Value\n &lt;dbl&gt; &lt;dbl&gt; &lt;chr&gt; &lt;dbl&gt;\n1 1913 85.0 Jan -5.09\n2 1913 85.0 Feb -5.55\n3 1913 85.0 Mar -9.18\n4 1914 39.2 Jan -3.99\n5 1914 39.2 Feb -7.88\n6 1914 39.2 Mar -5.31\n\n\nLine plot\n\n# LINE PLOT\nl = ggplot(dat2, aes(x = Year, y = Value, group = Month)) +\n geom_line(aes(color = Month)) +\n geom_point(aes(color = Month))\nl\n\n\n\n\nDensity plot\n\n# DENSITY PLOT\nd = ggplot(dat2, aes(x = Value))\nd = d + geom_density(aes(color = Month, fill = Month), alpha=0.4) # Alpha specifies transparency\nd\n\n\n\n\nHistogram\n\n# HISTOGRAM\nh = ggplot(dat2, aes(x = Value))\nh = h + geom_histogram(aes(color = Month, fill = Month), alpha=0.4,\n fill = \"white\",\n position = \"dodge\")\nh\n\n\n\n\nGrid plotting and saving files to disk\nThere are multiple ways to arrange multiple plots and save images. One method is using grid.arrange() which is found in the gridExtra package. You can then save the file using ggsave, which comes with the ggplot2 library.\n\n# The plots can be displayed together on one image using \n# grid.arrange from the gridExtra package\nimg = grid.arrange(l, d, h, nrow=3)\n\n\n\n# Finally, plots created using ggplot can be saved using ggsave\nggsave(\"grid_plot_1.png\", \n plot = img, \n device = \"png\", \n width = 6, \n height = 4, \n units = c(\"in\"), \n dpi = 600)\n\nAnother approach is to use the plot_grid function, which is in the cowplot library. Notice how the axes are now beautifally aligned.\n\nimg2=cowplot::plot_grid(l, d, h, nrow = 3, align = \"v\") # \"v\" aligns vertical axes and \"h\" aligns horizontal axes\n\nggsave(\"grid_plot_2.png\", \n plot = img2, \n device = \"png\", \n width = 6, \n height = 4, \n units = c(\"in\"), \n dpi = 600)\n\n Some useful resources\nThe links below offer a treasure trove of examples and sample code to get you started.\nThe R Graph Gallery: https://www.r-graph-gallery.com/\nLine plots in ggplot2: http://www.sthda.com/english/wiki/ggplot2-line-plot-quick-start-guide-r-software-and-data-visualization\nTop 50 visualizations with ggplot2: http://r-statistics.co/Top50-Ggplot2-Visualizations-MasterList-R-Code.html\nPractical guide in ggplot2: http://www.sthda.com/english/wiki/be-awesome-in-ggplot2-a-practical-guide-to-be-highly-effective-r-software-and-data-visualization"
}
]
Binary file modified grid_plot_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified grid_plot_2.png

0 comments on commit 5e239e2

Please sign in to comment.