In this recipe we will learn the simplest way to change the colors of points, lines, and bars in scatter plots, line plots, histograms, and bar plots.
All you need to try out this recipe is to run R and type the recipe at the command prompt. You can also choose to save the recipe as a script so that you can use it again later on.
The simplest way to change the color of any graph element is by using the
col argument. For example, the
plot() function takes the
If we choose plot type as line, then the color is applied to the plotted line. Let's ...