<?xml version="1.0" encoding="UTF-8" ?>
<!-- RSS generated by PHPBoost on Thu, 30 Apr 2026 05:50:58 +0200 -->

<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Easy Guides]]></title>
		<atom:link href="https://www.sthda.com/english/syndication/rss/wiki/22" rel="self" type="application/rss+xml"/>
		<link>https://www.sthda.com</link>
		<description><![CDATA[Last articles of the category: Data Visualization]]></description>
		<copyright>(C) 2005-2026 PHPBoost</copyright>
		<language>en</language>
		<generator>PHPBoost</generator>
		
		
		<item>
			<title><![CDATA[Data Visualization]]></title>
			<link>https://www.sthda.com/english/wiki/data-visualization</link>
			<guid>https://www.sthda.com/english/wiki/data-visualization</guid>
			<description><![CDATA[<!-- START HTML -->

  <!--====================== start from here when you copy to sthda================-->  
  <div id="rdoc">

<p><br/></p>
<p>Previously, we described the <a href="https://www.sthda.com/english/english/wiki/r-basics-quick-and-easy">essentials of R programming</a> and provided quick start guides for <a href="https://www.sthda.com/english/english/wiki/importing-data-into-r">importing data</a> into <strong>R</strong>.</p>
<br/>
<div class="block">
This chapter describes how to <strong>plot</strong> data in <strong>R</strong> and make elegant data <strong>visualization</strong>.
</div>
<p><br/></p>
<div id="how-this-chapter-is-organized" class="section level1">
<h1>How this chapter is organized?</h1>
<br/>
<div class="block">
<ul>
<li><a href="https://www.sthda.com/english/english/wiki/r-base-graphs">R Base Graphs</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/lattice-graphs">Lattice Graphs</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/ggplot2-essentials">ggplot2</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/3d-graphics">3D Graphics</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/the-elements-of-choosing-colors-for-great-data-visualization-in-r">The Elements of Choosing Colors for Great Data Visualization in R</a></li>
</ul>
</div>
<p><br/></p>
<hr/>
</div>
<div id="r-base-graphs" class="section level1">
<h1>R Base Graphs</h1>
<p><img src="https://www.sthda.com/english/sthda/RDoc/figure/graphs/data-visualization-r-base-graphs-box-plot-change-1.png" width="288" /></p>
<ol style="list-style-type: decimal">
<li><a href="https://www.sthda.com/english/english/wiki/r-base-graphs">R Base Plots</a>
<ul>
<li><a href="https://www.sthda.com/english/english/wiki/creating-and-saving-graphs-r-base-graphs">Creating and Saving Graphs in R</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/generic-plot-types-in-r-software">Generic plot types in R</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/scatter-plots-r-base-graphs">Scatter Plots</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/scatter-plot-matrices-r-base-graphs">Scatter Plot Matrices</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/box-plots-r-base-graphs">Box Plots</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/strip-charts-1-d-scatter-plots-r-base-graphs">Strip Charts: 1-D scatter Plots</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/bar-plots-r-base-graphs">Bar Plots</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/line-plots-r-base-graphs">Line Plots</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/pie-charts-r-base-graphs">Pie Charts</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/histogram-and-density-plots-r-base-graphs">Histogram and Density Plots</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/dot-charts-r-base-graphs">Dot Charts</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/plot-group-means-and-confidence-intervals-r-base-graphs">Plot Group Means and Confidence Intervals</a></li>
</ul></li>
<li><a href="https://www.sthda.com/english/english/wiki/graphical-parameters">R Base Graphical Parameters</a>
<ul>
<li><a href="https://www.sthda.com/english/english/wiki/add-titles-to-a-plot-in-r-software">Add and customize titles</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/add-legends-to-plots-in-r-software-the-easiest-way">Add and customize legends</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/add-text-to-a-plot-in-r-software">Add texts</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/abline-r-function-an-easy-way-to-add-straight-lines-to-a-plot-using-r-software">Add straight lines: vertical, horizontal and regression lines</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/wiki/add-an-axis-to-a-plot-with-r-software">Add an axis</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/axis-scale-in-r-software-minimum-maximum-and-log-scale">Change axis scale: minimum, maximum and log scale</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/add-custom-tick-mark-labels-to-a-plot-in-r-software">Customize tick mark labels</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/r-plot-pch-symbols-the-different-point-shapes-available-in-r">Change point shapes</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/line-types-in-r-lty">Change line types</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/colors-in-r">Change colors</a></li>
</ul></li>
</ol>
<p><span class="success">Read more: —> <a href="https://www.sthda.com/english/english/wiki/r-base-graphs">R base Graphs</a>.</span></p>
</div>
<div id="lattice-graphs" class="section level1">
<h1>Lattice Graphs</h1>
<br/>
<div class="block">
<strong>Lattice</strong> package is a powerful and elegant data visualization system that aims to improve on base R graphs.
</div>
<p><br/></p>
<p><img src="https://www.sthda.com/english/sthda/RDoc/figure/graphs/data-visualization-basic-box-plot-dot-plot-1.png" width="288" /></p>
<ul>
<li>xyplot(): Scatter plot</li>
<li>cloud(): 3D scatter plot</li>
<li>Box plot, Dot plot, Strip plot</li>
<li>Density plot and Histogram</li>
</ul>
<p><span class="success">Read more: —> <a href="https://www.sthda.com/english/english/wiki/lattice-graphs">Lattice Graphs</a>.</span></p>
</div>
<div id="ggplot2" class="section level1">
<h1>Ggplot2</h1>
<br/>
<div class="block">
<strong>ggplot2</strong> is a powerful and a flexible <strong>R package</strong>, implemented by <strong>Hadley Wickham</strong>, for producing elegant graphics.
</div>
<p><br/></p>
<p><img src="https://www.sthda.com/english/sthda/RDoc/figure/graphs/data-visualization-ggplot2-1.png" width="384" /></p>
<ol style="list-style-type: decimal">
<li><a href="https://www.sthda.com/english/english/wiki/ggplot2-essentials">ggplots</a>
<ul>
<li><a href="https://www.sthda.com/english/english/wiki/qplot-quick-plot-with-ggplot2-r-software-and-data-visualization">qplot(): Quick plot with ggplot2</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/ggplot2-box-plot-quick-start-guide-r-software-and-data-visualization">Box plots</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/ggplot2-violin-plot-quick-start-guide-r-software-and-data-visualization">Violin plots</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/ggplot2-dot-plot-quick-start-guide-r-software-and-data-visualization">Dot plots</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/ggplot2-stripchart-jitter-quick-start-guide-r-software-and-data-visualization">Stripcharts</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/ggplot2-density-plot-quick-start-guide-r-software-and-data-visualization">Density plots</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/ggplot2-histogram-plot-quick-start-guide-r-software-and-data-visualization">Histogram plots</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/ggplot2-scatter-plots-quick-start-guide-r-software-and-data-visualization">Scatter plots</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/ggplot2-barplots-quick-start-guide-r-software-and-data-visualization">Bar plots</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/ggplot2-line-types-how-to-change-line-types-of-a-graph-in-r-software">Line plots</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/ggplot2-error-bars-quick-start-guide-r-software-and-data-visualization">Error bars</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/ggplot2-pie-chart-quick-start-guide-r-software-and-data-visualization">Pie chart</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/ggplot2-qq-plot-quantile-quantile-graph-quick-start-guide-r-software-and-data-visualization">QQ plots</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/ggplot2-ecdf-plot-quick-start-guide-for-empirical-cumulative-density-function-r-software-and-data-visualization">ECDF plots</a></li>
</ul></li>
<li><p><a href="https://www.sthda.com/english/english/wiki/ggsave-save-a-ggplot-r-software-and-data-visualization">ggsave(): Save a ggplot</a></p></li>
<li><strong>ggplot2 Graphical Parameters</strong>
<ul>
<li><a href="https://www.sthda.com/english/english/wiki/ggplot2-title-main-axis-and-legend-titles">Main title, axis labels and legend title</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/ggplot2-legend-easy-steps-to-change-the-position-and-the-appearance-of-a-graph-legend-in-r-software">Legend position and appearance</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/ggplot2-colors-how-to-change-colors-automatically-and-manually">Change colors automatically and manually</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/ggplot2-point-shapes">Point shapes, colors and size</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/ggplot2-texts-add-text-annotations-to-a-graph-in-r-software">Add text annotations to a graph</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/ggplot2-line-types-how-to-change-line-types-of-a-graph-in-r-software">Line types</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/ggplot2-themes-and-background-colors-the-3-elements">Themes and background colors</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/ggplot2-axis-scales-and-transformations">Axis scales and transformations</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/ggplot2-axis-ticks-a-guide-to-customize-tick-marks-and-labels">Axis ticks: customize tick marks and labels, reorder and select items</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/ggplot2-add-straight-lines-to-a-plot-horizontal-vertical-and-regression-lines">Add straight lines to a plot: horizontal, vertical and regression lines</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/ggplot2-rotate-a-graph-reverse-and-flip-the-plot">Rotate a plot: flip and reverse</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/ggplot2-facet-split-a-plot-into-a-matrix-of-panels">Faceting: split a plot into a matrix of panels</a></li>
</ul></li>
<li><strong>Cheat Sheets</strong>
<ul>
<li><a href="https://www.sthda.com/english/english/wiki/be-awesome-in-ggplot2-a-practical-guide-to-be-highly-effective-r-software-and-data-visualization">Be Awesome in ggplot2: A Practical Guide to be Highly Effective</a></li>
</ul></li>
</ol>
<p><span class="success">Read more: —> <a href="https://www.sthda.com/english/english/wiki/ggplot2-essentials">ggplot2 essentials</a>.</span></p>
</div>
<div id="d-graphics" class="section level1">
<h1>3D Graphics</h1>
<div class="figure">
<img src="https://www.sthda.com/english/sthda/RDoc/images/rgl-scatter3d.gif" alt="3d scatter plot rgl" /><p class="caption">3d scatter plot rgl</p>
</div>
<ol style="list-style-type: decimal">
<li>Static 3D Scatter Plots
<ul>
<li><a href="https://www.sthda.com/english/english/wiki/scatterplot3d-3d-graphics-r-software-and-data-visualization">Simple 3D Scatter Plots: scatterplot3d Package</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/impressive-package-for-3d-and-4d-graph-r-software-and-data-visualization">Advanced 3D Graphs: plot3D Package</a></li>
</ul></li>
<li>Interactive 3D Graphs
<ul>
<li><a href="https://www.sthda.com/english/english/wiki/amazing-interactive-3d-scatter-plots-r-software-and-data-visualization">Interactive 3D Scatter Plots</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/a-complete-guide-to-3d-visualization-device-system-in-r-r-software-and-data-visualization">Guide to RGL 3D Visualization System</a></li>
</ul></li>
</ol>
<p><span class="success">Read more: —> <a href="https://www.sthda.com/english/english/wiki/3d-graphics">3D Graphics</a>.</span></p>
</div>
<div id="others" class="section level1">
<h1>Others</h1>
<ul>
<li><a href="https://www.sthda.com/english/english/wiki/the-elements-of-choosing-colors-for-great-data-visualization-in-r">The Elements of Choosing Colors for Great Data Visualization in R</a></li>
</ul>
</div>
<div id="infos" class="section level1">
<h1>Infos</h1>
<p><span class="warning"> This analysis has been performed using <strong>R statistical software</strong> (ver. 3.2.4). </span></p>
</div>

<script>jQuery(document).ready(function () {
    jQuery('#rdoc h1').addClass('wiki_paragraph1');
    jQuery('#rdoc h2').addClass('wiki_paragraph2');
    jQuery('#rdoc h3').addClass('wiki_paragraph3');
    jQuery('#rdoc h4').addClass('wiki_paragraph4');
    });//add phpboost class to header</script>
<style>.content{padding:0px;}</style>
</div><!--end rdoc-->
<!--====================== stop here when you copy to sthda================-->


<!-- END HTML -->]]></description>
			<pubDate>Tue, 12 Jul 2016 09:52:40 +0200</pubDate>
			
		</item>
		
		<item>
			<title><![CDATA[Lattice Graphs]]></title>
			<link>https://www.sthda.com/english/wiki/lattice-graphs</link>
			<guid>https://www.sthda.com/english/wiki/lattice-graphs</guid>
			<description><![CDATA[<!-- START HTML -->

  <!--====================== start from here when you copy to sthda================-->  
  <div id="rdoc">


<div id="TOC">
<ul>
<li><a href="#pleleminary-tasks">Pleleminary tasks</a></li>
<li><a href="#installing-and-loading-the-lattice-package">Installing and loading the lattice package</a></li>
<li><a href="#main-functions-in-the-lattice-package">Main functions in the lattice package</a></li>
<li><a href="#xyplot-scatter-plot">xyplot(): Scatter plot</a></li>
<li><a href="#cloud-3d-scatter-plot">cloud(): 3D scatter plot</a></li>
<li><a href="#box-plot-dot-plot-strip-plot">Box plot, Dot plot, Strip plot</a></li>
<li><a href="#density-plot-and-histogram">Density plot and Histogram</a></li>
<li><a href="#see-also">See also</a></li>
<li><a href="#infos">Infos</a></li>
</ul>
</div>

<p><br/></p>
<p>Previously, we described the <a href="https://www.sthda.com/english/english/wiki/r-basics-quick-and-easy">essentials of R programming</a> and provided quick start guides for <a href="https://www.sthda.com/english/english/wiki/importing-data-into-r">importing data</a> into <strong>R</strong>. We also showed how to <strong>visualize</strong> data using <a href="https://www.sthda.com/english/english/wiki/r-base-graphs">R base graphs</a>.</p>
<br/>
<div class="block">
Here, we’ll present the basics <strong>lattice</strong> package, which is a powerful and elegant data visualization system that aims to improve on base R graphs.
</div>
<p><br/></p>
<div id="pleleminary-tasks" class="section level1">
<h1>Pleleminary tasks</h1>
<ol style="list-style-type: decimal">
<li><p><strong>Launch RStudio</strong> as described here: <a href="https://www.sthda.com/english/english/wiki/running-rstudio-and-setting-up-your-working-directory-easy-r-programming">Running RStudio and setting up your working directory</a></p></li>
<li><p><strong>Prepare your data</strong> as described here: <a href="https://www.sthda.com/english/english/wiki/best-practices-in-preparing-data-files-for-importing-into-r">Best practices for preparing your data</a> and save it in an external .txt tab or .csv files</p></li>
<li><p><strong>Import your data</strong> into <strong>R</strong> as described here: <a href="https://www.sthda.com/english/english/wiki/fast-reading-of-data-from-txt-csv-files-into-r-readr-package">Fast reading of data from txt|csv files into R: readr package</a>.</p></li>
</ol>
<p>Briefly, if your data is saved in an external .txt tab or .csv files, use the following script to import the data into R:</p>
<pre class="r"><code># If .txt tab file use this:
my_data <- read.delim(file.choose())

# or if .csv file:
my_data <- read.csv(file.choose())</code></pre>
<p><span class="notice">In the following sections, we’ll use R built-in data sets.</span></p>
</div>
<div id="installing-and-loading-the-lattice-package" class="section level1">
<h1>Installing and loading the lattice package</h1>
<pre class="r"><code># Install
install.packages("lattice")

# Load
library("lattice")</code></pre>
</div>
<div id="main-functions-in-the-lattice-package" class="section level1">
<h1>Main functions in the lattice package</h1>
<table>
<thead>
<tr class="header">
<th align="left">Function</th>
<th align="left">Description</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">xyplot()</td>
<td align="left">Scatter plot</td>
</tr>
<tr class="even">
<td align="left">splom()</td>
<td align="left">Scatter plot matrix</td>
</tr>
<tr class="odd">
<td align="left">cloud()</td>
<td align="left">3D scatter plot</td>
</tr>
<tr class="even">
<td align="left">stripplot()</td>
<td align="left">strip plots (1-D scatter plots)</td>
</tr>
<tr class="odd">
<td align="left">bwplot()</td>
<td align="left">Box plot</td>
</tr>
<tr class="even">
<td align="left">dotplot()</td>
<td align="left">Dot plot</td>
</tr>
<tr class="odd">
<td align="left">barchart()</td>
<td align="left">bar chart</td>
</tr>
<tr class="even">
<td align="left">histogram()</td>
<td align="left">Histogram</td>
</tr>
<tr class="odd">
<td align="left">densityplot</td>
<td align="left">Kernel density plot</td>
</tr>
<tr class="even">
<td align="left">qqmath()</td>
<td align="left">Theoretical quantile plot</td>
</tr>
<tr class="odd">
<td align="left">qq()</td>
<td align="left">Two-sample quantile plot</td>
</tr>
<tr class="even">
<td align="left">contourplot()</td>
<td align="left">3D contour plot of surfaces</td>
</tr>
<tr class="odd">
<td align="left">levelplot()</td>
<td align="left">False color level plot of surfaces</td>
</tr>
<tr class="even">
<td align="left">parallel()</td>
<td align="left">Parallel coordinates plot</td>
</tr>
<tr class="odd">
<td align="left">wireframe()</td>
<td align="left">3D wireframe graph</td>
</tr>
</tbody>
</table>
<p><span class="notice">Note that, other functions (<strong>ecdfplot</strong>() and <strong>mapplot</strong>()) are available in the <strong>latticeExtra</strong> package.</span></p>
</div>
<div id="xyplot-scatter-plot" class="section level1">
<h1>xyplot(): Scatter plot</h1>
<ul>
<li><strong>R function</strong>: The R function <strong>xyplot</strong>() is used to produce bivariate scatter plots or time-series plots. The simplified format is as follow:</li>
</ul>
<pre class="r"><code>xyplot(y ~ x, data)</code></pre>
<ul>
<li><strong>Data set</strong>: mtcars</li>
</ul>
<pre class="r"><code>my_data <- iris
head(my_data)</code></pre>
<pre><code>##   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1          5.1         3.5          1.4         0.2  setosa
## 2          4.9         3.0          1.4         0.2  setosa
## 3          4.7         3.2          1.3         0.2  setosa
## 4          4.6         3.1          1.5         0.2  setosa
## 5          5.0         3.6          1.4         0.2  setosa
## 6          5.4         3.9          1.7         0.4  setosa</code></pre>
<ul>
<li><strong>Basic scatter plot</strong>: y ~ x</li>
</ul>
<pre class="r"><code># Default plot
xyplot(Sepal.Length ~ Petal.Length, data = my_data)</code></pre>
<p><img src="https://www.sthda.com/english/sthda/RDoc/figure/graphs/lattice-graphs-lattice-scatter-plot-1.png" title="" alt="" width="384" /></p>
<pre class="r"><code># Color by groups
xyplot(Sepal.Length ~ Petal.Length, group = Species, 
       data = my_data, auto.key = TRUE)</code></pre>
<p><img src="https://www.sthda.com/english/sthda/RDoc/figure/graphs/lattice-graphs-lattice-scatter-plot-2.png" title="" alt="" width="384" /></p>
<pre class="r"><code># Show points ("p"), grids ("g") and smoothing line
# Change xlab and ylab
xyplot(Sepal.Length ~ Petal.Length, data = my_data,
       type = c("p", "g", "smooth"),
       xlab = "Miles/(US) gallon", ylab = "Weight (1000 lbs)")</code></pre>
<p><img src="https://www.sthda.com/english/sthda/RDoc/figure/graphs/lattice-graphs-lattice-scatter-plot-3.png" title="" alt="" width="384" /></p>
<ul>
<li><strong>Multiple panels by groups</strong>: y ~ x | group</li>
</ul>
<pre class="r"><code>xyplot(Sepal.Length ~ Petal.Length | Species, 
       group = Species, data = my_data,
       type = c("p", "smooth"),
       scales = "free")</code></pre>
<p><img src="https://www.sthda.com/english/sthda/RDoc/figure/graphs/lattice-graphs-lattice-scatter-plot-panels-1.png" title="" alt="" width="480" /></p>
</div>
<div id="cloud-3d-scatter-plot" class="section level1">
<h1>cloud(): 3D scatter plot</h1>
<ul>
<li><strong>Data set</strong>: iris</li>
</ul>
<pre class="r"><code>my_data <- iris
head(my_data)</code></pre>
<pre><code>##   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1          5.1         3.5          1.4         0.2  setosa
## 2          4.9         3.0          1.4         0.2  setosa
## 3          4.7         3.2          1.3         0.2  setosa
## 4          4.6         3.1          1.5         0.2  setosa
## 5          5.0         3.6          1.4         0.2  setosa
## 6          5.4         3.9          1.7         0.4  setosa</code></pre>
<ul>
<li><strong>Scatter 3D plot</strong>: z ~ x * y</li>
</ul>
<pre class="r"><code># Basic 3D scatter plot
cloud(Sepal.Length ~ Sepal.Length * Petal.Width, 
       data = iris)</code></pre>
<p><img src="https://www.sthda.com/english/sthda/RDoc/figure/graphs/lattice-graphs-3D-sactter-plot-1.png" title="" alt="" width="336" /></p>
<pre class="r"><code># Color by groups; auto.key = TRUE to show legend
cloud(Sepal.Length ~ Sepal.Length * Petal.Width, 
       group = Species, data = iris,
       auto.key = TRUE)</code></pre>
<p><img src="https://www.sthda.com/english/sthda/RDoc/figure/graphs/lattice-graphs-3D-sactter-plot-2.png" title="" alt="" width="336" /></p>
</div>
<div id="box-plot-dot-plot-strip-plot" class="section level1">
<h1>Box plot, Dot plot, Strip plot</h1>
<ul>
<li><strong>Data set</strong>: ToothGrowth</li>
</ul>
<pre class="r"><code>ToothGrowth$dose <- as.factor(ToothGrowth$dose)
head(ToothGrowth)</code></pre>
<pre><code>##    len supp dose
## 1  4.2   VC  0.5
## 2 11.5   VC  0.5
## 3  7.3   VC  0.5
## 4  5.8   VC  0.5
## 5  6.4   VC  0.5
## 6 10.0   VC  0.5</code></pre>
<ul>
<li><strong>Basic plot</strong>: Plot len by dose</li>
</ul>
<pre class="r"><code># Basic box plot
bwplot(len ~ dose,  data = ToothGrowth,
       xlab = "Dose", ylab = "Length")

# Violin plot using panel = panel.violin
bwplot(len ~ dose,  data = ToothGrowth,
       panel = panel.violin,
       xlab = "Dose", ylab = "Length")
   
# Basic dot plot
dotplot(len ~ dose,  data = ToothGrowth,
        xlab = "Dose", ylab = "Length")

# Basic stip plot
stripplot(len ~ dose,  data = ToothGrowth,
          jitter.data = TRUE, pch = 19,
          xlab = "Dose", ylab = "Length")</code></pre>
<p><img src="https://www.sthda.com/english/sthda/RDoc/figure/graphs/lattice-graphs-basic-box-plot-dot-plot-1.png" title="" alt="" width="259.2" /><img src="https://www.sthda.com/english/sthda/RDoc/figure/graphs/lattice-graphs-basic-box-plot-dot-plot-2.png" title="" alt="" width="259.2" /><img src="https://www.sthda.com/english/sthda/RDoc/figure/graphs/lattice-graphs-basic-box-plot-dot-plot-3.png" title="" alt="" width="259.2" /><img src="https://www.sthda.com/english/sthda/RDoc/figure/graphs/lattice-graphs-basic-box-plot-dot-plot-4.png" title="" alt="" width="259.2" /></p>
<ul>
<li><strong>Plot with multiple groups</strong>: Additional argument <strong>layout</strong> is used: c(3, 1) specifying the number of column and row, respectively</li>
</ul>
<pre class="r"><code># Box plot
bwplot(len ~ supp | dose,  data = ToothGrowth,
       layout = c(3, 1),
        xlab = "Dose", ylab = "Length")

# Violin plot
bwplot(len ~ supp | dose,  data = ToothGrowth,
       layout = c(3, 1), panel = panel.violin,
        xlab = "Dose", ylab = "Length")

# Dot plot
dotplot(len ~ supp | dose,  data = ToothGrowth,
       layout = c(3, 1),
        xlab = "Dose", ylab = "Length")

# Strip plot
stripplot(len ~ supp | dose,  data = ToothGrowth,
       layout = c(3, 1), jitter.data = TRUE,
        xlab = "Dose", ylab = "Length")</code></pre>
<p><img src="https://www.sthda.com/english/sthda/RDoc/figure/graphs/lattice-graphs-box-plot-dot-plot-strip-plot-groups-1.png" title="" alt="" width="518.4" /><img src="https://www.sthda.com/english/sthda/RDoc/figure/graphs/lattice-graphs-box-plot-dot-plot-strip-plot-groups-2.png" title="" alt="" width="518.4" /><img src="https://www.sthda.com/english/sthda/RDoc/figure/graphs/lattice-graphs-box-plot-dot-plot-strip-plot-groups-3.png" title="" alt="" width="518.4" /><img src="https://www.sthda.com/english/sthda/RDoc/figure/graphs/lattice-graphs-box-plot-dot-plot-strip-plot-groups-4.png" title="" alt="" width="518.4" /></p>
</div>
<div id="density-plot-and-histogram" class="section level1">
<h1>Density plot and Histogram</h1>
<ul>
<li>Basic plots</li>
</ul>
<pre class="r"><code>densityplot(~ len, data = ToothGrowth,
            plot.points = FALSE)

histogram(~ len, data = ToothGrowth,
            breaks = 20)</code></pre>
<p><img src="https://www.sthda.com/english/sthda/RDoc/figure/graphs/lattice-graphs-lattice-density-plot-1.png" title="" alt="" width="432" /><img src="https://www.sthda.com/english/sthda/RDoc/figure/graphs/lattice-graphs-lattice-density-plot-2.png" title="" alt="" width="432" /></p>
<ul>
<li>Plot with multiple groups</li>
</ul>
<pre class="r"><code>densityplot(~ len, groups = dose, data = ToothGrowth,
            plot.points = FALSE, auto.key = TRUE)</code></pre>
<p><img src="https://www.sthda.com/english/sthda/RDoc/figure/graphs/lattice-graphs-lattice-density-plot-groups-1.png" title="" alt="" width="480" /></p>
</div>
<div id="see-also" class="section level1">
<h1>See also</h1>
<ol style="list-style-type: decimal">
<li><a href="https://www.sthda.com/english/english/wiki/r-base-graphs">R base plots</a>
<ul>
<li><a href="https://www.sthda.com/english/english/wiki/creating-and-saving-graphs-r-base-graphs">Creating and Saving Graphs in R</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/scatter-plots-r-base-graphs">Scatter Plots</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/scatter-plot-matrices-r-base-graphs">Scatter Plot Matrices</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/box-plots-r-base-graphs">Box Plots</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/strip-charts-1-d-scatter-plots-r-base-graphs">Strip Charts: 1-D scatter Plots</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/bar-plots-r-base-graphs">Bar Plots</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/line-plots-r-base-graphs">Line Plots</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/pie-charts-r-base-graphs">Pie Charts</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/histogram-and-density-plots-r-base-graphs">Histogram and Density Plots</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/dot-charts-r-base-graphs">Dot Charts</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/plot-group-means-and-confidence-intervals-r-base-graphs">Plot Group Means and Confidence Intervals</a></li>
<li><a href="https://www.sthda.com/english/english/wiki/graphical-parameters">Graphical Parameters</a></li>
</ul></li>
<li><a href="https://www.sthda.com/english/english/wiki/ggplot2-essentials">ggplot2 Graphs</a></li>
</ol>
</div>
<div id="infos" class="section level1">
<h1>Infos</h1>
<p><span class="warning"> This analysis has been performed using <strong>R statistical software</strong> (ver. 3.2.4). </span></p>
</div>

<script>jQuery(document).ready(function () {
    jQuery('h1').addClass('wiki_paragraph1');
    jQuery('h2').addClass('wiki_paragraph2');
    jQuery('h3').addClass('wiki_paragraph3');
    jQuery('h4').addClass('wiki_paragraph4');
    });//add phpboost class to header</script>
<style>.content{padding:0px;}</style>
</div><!--end rdoc-->
<!--====================== stop here when you copy to sthda================-->


<!-- END HTML -->]]></description>
			<pubDate>Sat, 07 May 2016 08:16:14 +0200</pubDate>
			
		</item>
		
		<item>
			<title><![CDATA[The Elements of Choosing Colors for Great Data Visualization in R]]></title>
			<link>https://www.sthda.com/english/wiki/the-elements-of-choosing-colors-for-great-data-visualization-in-r</link>
			<guid>https://www.sthda.com/english/wiki/the-elements-of-choosing-colors-for-great-data-visualization-in-r</guid>
			<description><![CDATA[<!-- START HTML -->

  <!--====================== start from here when you copy to sthda================-->  
  <div id="rdoc">


<div id="TOC">
<ul>
<li><a href="#understanding-color-wheel">Understanding color wheel</a></li>
<li><a href="#defining-the-basics-for-choosing-colors">Defining the basics for choosing colors</a></li>
<li><a href="#colortools-r-package-for-creating-easily-color-schemes-in-r">colortools: R package for creating easily color schemes in R</a><ul>
<li><a href="#install-colortools">Install colortools</a></li>
<li><a href="#load-colortools">Load colortools</a></li>
<li><a href="#color-wheel">Color wheel</a></li>
<li><a href="#analogous-color-scheme">Analogous color scheme</a></li>
<li><a href="#complementary-color-scheme">Complementary color scheme</a></li>
<li><a href="#split-complementary-color-scheme">Split Complementary Color Scheme</a></li>
<li><a href="#tetradic-color-scheme">Tetradic Color Scheme</a></li>
<li><a href="#square-color-scheme">Square color scheme</a></li>
<li><a href="#sequential-colors">Sequential colors</a></li>
</ul></li>
<li><a href="#design-your-color-scheme-online">Design your color scheme online</a></li>
<li><a href="#read-more">Read more</a></li>
<li><a href="#infos">Infos</a></li>
</ul>
</div>

<p><br/></p>
<p><strong>Color</strong> is crucial for elegant <strong>data visualization</strong>. In our previous article we describe the list of <a href="https://www.sthda.com/english/english/wiki/colors-in-r">color palettes</a> available in R.</p>
<p>In this current article we define the basics for using the power of color and, we describe an R package and an online tool for generating beautiful <strong>color schemes</strong>.</p>
<div id="understanding-color-wheel" class="section level1">
<h1>Understanding color wheel</h1>
<p><img src="https://www.sthda.com/english/sthda/RDoc/images/color-wheel.png" alt="color wheel" /></p>
<p>(Image from Nancy Duarte, slide:ology)</p>
<p>The <strong>color wheel</strong> helps you to visualize the relationships between <strong>colors</strong>.</p>
<p>The wheel is divided into pie slices which have the following components:</p>
<ul>
<li><strong>hue</strong> (true color): On the wheel above, the hue is four rings out of the center.</li>
<li><strong>tints</strong>: correspond to the colors toward the center of the wheel (= hue + white color)</li>
<li><strong>shades</strong>: corresponds to the ring of colors on the outside of the hue ( = hue + black color)</li>
</ul>
</div>
<div id="defining-the-basics-for-choosing-colors" class="section level1">
<h1>Defining the basics for choosing colors</h1>
<ol style="list-style-type: decimal">
<li><p><strong>Monochromatic</strong>: Variations of the same color.</p></li>
<li><p><strong>Analogous</strong>: colors that are touching in the wheel creates narrow <strong>harmonious color scheme</strong>.</p></li>
<li><p><strong>Complementary</strong>: Colors from the opposite ends of the wheel provide the most <strong>contrast</strong>.</p></li>
</ol>
<p><img src="https://www.sthda.com/english/sthda/RDoc/images/color-wheel-basics.png" alt="color wheel basics" /></p>
<p>(Image from Nancy Duarte, slide:ology) 
</p>
<ol start="4" style="list-style-type: decimal">
<li><p><strong>Split Complementary</strong>: A variation of the complementary scheme that uses two colors on either side of a directly complementary color. These colors have high visual contrast but with less visual tension than purely complementary colors.</p></li>
<li><p><strong>Triadic</strong>: Three colors equally spaced around the color wheel create vivid visual interest.</p></li>
<li><p><strong>Tetradic</strong>: Two pairs of complementary colors. This scheme is popular because it offers strong visual contrast while retaining harmony.</p></li>
</ol>
<p><img src="https://www.sthda.com/english/sthda/RDoc/images/color-wheel-basics-2.png" alt="color wheel basics" /></p>
<p>(Image from Nancy Duarte, slide:ology)</p>
<p>
</p>
</div>
<div id="colortools-r-package-for-creating-easily-color-schemes-in-r" class="section level1">
<h1>colortools: R package for creating easily color schemes in R</h1>
<p>The excellent R package <strong>colortools</strong> developed by <a href="http://gastonsanchez.com/software/">Gaston Sanchez</a> is an easy to use solution for generating color schemes in R.</p>
<div id="install-colortools" class="section level2">
<h2>Install colortools</h2>
<pre class="r"><code>install.packages("colortools")</code></pre>
</div>
<div id="load-colortools" class="section level2">
<h2>Load colortools</h2>
<pre class="r"><code>library(colortools)</code></pre>
</div>
<div id="color-wheel" class="section level2">
<h2>Color wheel</h2>
<p>The function <strong>wheel</strong>() can be used to generate a color wheel for a given color:</p>
<pre class="r"><code>wheel("darkblue", num = 12)</code></pre>
<pre><code>##  [1] "#00008B" "#46008B" "#8B008B" "#8B0046" "#8B0000" "#8B4500" "#8B8B00"
##  [8] "#468B00" "#008B00" "#008B45" "#008B8B" "#00468B"</code></pre>
<p><img src="https://www.sthda.com/english/sthda/RDoc/figure/data-visualization/choose-colors--color-wheel-1.png" title="The Elements of Choosing Colors for Great Data Visualization in R." alt="The Elements of Choosing Colors for Great Data Visualization in R." width="432" /></p>
</div>
<div id="analogous-color-scheme" class="section level2">
<h2>Analogous color scheme</h2>
<p>The function <strong>adjacent</strong>() or <strong>analogous</strong>() can be used:</p>
<pre class="r"><code>analogous("darkblue")</code></pre>
<pre><code>## [1] "#00008B" "#46008B" "#00468B"</code></pre>
<p><img src="https://www.sthda.com/english/sthda/RDoc/figure/data-visualization/choose-colors-analogous-color-1.png" title="The Elements of Choosing Colors for Great Data Visualization in R." alt="The Elements of Choosing Colors for Great Data Visualization in R." width="432" /></p>
</div>
<div id="complementary-color-scheme" class="section level2">
<h2>Complementary color scheme</h2>
<pre class="r"><code>complementary("steelblue")</code></pre>
<pre><code>## [1] "#4682B4" "#B47846"</code></pre>
<p><img src="https://www.sthda.com/english/sthda/RDoc/figure/data-visualization/choose-colors-complementary-color-scheme-1.png" title="The Elements of Choosing Colors for Great Data Visualization in R." alt="The Elements of Choosing Colors for Great Data Visualization in R." width="432" /></p>
</div>
<div id="split-complementary-color-scheme" class="section level2">
<h2>Split Complementary Color Scheme</h2>
<pre class="r"><code>splitComp("steelblue")</code></pre>
<pre><code>## [1] "#4682B4" "#B4464B" "#B4AF46"</code></pre>
<p><img src="https://www.sthda.com/english/sthda/RDoc/figure/data-visualization/choose-colors-split-complementary-1.png" title="The Elements of Choosing Colors for Great Data Visualization in R." alt="The Elements of Choosing Colors for Great Data Visualization in R." width="432" /></p>
</div>
<div id="tetradic-color-scheme" class="section level2">
<h2>Tetradic Color Scheme</h2>
<pre class="r"><code>tetradic("steelblue")</code></pre>
<pre><code>## [1] "#4682B4" "#7846B4" "#B47846" "#82B446"</code></pre>
<p><img src="https://www.sthda.com/english/sthda/RDoc/figure/data-visualization/choose-colors-tetradic-color-1.png" title="The Elements of Choosing Colors for Great Data Visualization in R." alt="The Elements of Choosing Colors for Great Data Visualization in R." width="432" /></p>
</div>
<div id="square-color-scheme" class="section level2">
<h2>Square color scheme</h2>
<pre class="r"><code>square("steelblue")</code></pre>
<pre><code>## [1] "#4682B4" "#AF46B4" "#B47846" "#4BB446"</code></pre>
<p><img src="https://www.sthda.com/english/sthda/RDoc/figure/data-visualization/choose-colors-square-1.png" title="The Elements of Choosing Colors for Great Data Visualization in R." alt="The Elements of Choosing Colors for Great Data Visualization in R." width="432" /></p>
</div>
<div id="sequential-colors" class="section level2">
<h2>Sequential colors</h2>
<pre class="r"><code>sequential("steelblue")</code></pre>
<pre><code>##  [1] "#B4B4B4FF" "#ABB0B4FF" "#A2ACB4FF" "#99A8B4FF" "#90A4B4FF"
##  [6] "#87A0B4FF" "#7E9BB4FF" "#7597B4FF" "#6C93B4FF" "#638FB4FF"
## [11] "#5A8BB4FF" "#5187B4FF" "#4883B4FF" "#3F7FB4FF" "#367BB4FF"
## [16] "#2D77B4FF" "#2473B4FF" "#1B6EB4FF" "#126AB4FF" "#0966B4FF"
## [21] "#0062B4FF"</code></pre>
<p><img src="https://www.sthda.com/english/sthda/RDoc/figure/data-visualization/choose-colors-sequential-colors-1.png" title="The Elements of Choosing Colors for Great Data Visualization in R." alt="The Elements of Choosing Colors for Great Data Visualization in R." width="432" /></p>
</div>
</div>
<div id="design-your-color-scheme-online" class="section level1">
<h1>Design your color scheme online</h1>
<p>The online tool <a href="http://colorschemedesigner.com/csd-3.5/">Colors Scheme Designer</a> can be used:</p>
<p><img src="https://www.sthda.com/english/sthda/RDoc/images/color-scheme-designer.png" alt="colors scheme designer" /></p>
</div>
<div id="read-more" class="section level1">
<h1>Read more</h1>
<ul>
<li><strong>slide:ology</strong>: The Art and Science of Creating Great Presentations (by Nancy Duarte)</li>
<li><a href="http://rpubs.com/gaston/colortools"><strong>R package colortools</strong></a> by Gaston Sanchez.</li>
</ul>
</div>
<div id="infos" class="section level1">
<h1>Infos</h1>
<p><span class="warning"> This analysis has been performed using <strong>R software</strong> (ver. 3.2.3) and <strong>colortools</strong> (ver. 0.1.5) </span></p>
</div>

<script>jQuery(document).ready(function () {
    jQuery('h1').addClass('wiki_paragraph1');
    jQuery('h2').addClass('wiki_paragraph2');
    jQuery('h3').addClass('wiki_paragraph3');
    jQuery('h4').addClass('wiki_paragraph4');
    });//add phpboost class to header</script>
<style>.content{padding:0px;}</style>
</div><!--end rdoc-->
<!--====================== stop here when you copy to sthda================-->

<!-- END HTML -->]]></description>
			<pubDate>Tue, 05 Jan 2016 14:50:42 +0100</pubDate>
			
		</item>
		
	</channel>
</rss>
