Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying R Graphs Cookbook Second Edition
  • Table Of Contents Toc
R Graphs Cookbook Second Edition

R Graphs Cookbook Second Edition - Second Edition

By : Jaynal Abedin, Hrishi V. Mittal
4 (2)
close
close
R Graphs Cookbook Second Edition

R Graphs Cookbook Second Edition

4 (2)
By: Jaynal Abedin, Hrishi V. Mittal

Overview of this book

Targeted at those with an existing familiarity with R programming, this practical guide will appeal directly to programmers interested in learning effective data visualization techniques with R and a wide-range of its associated libraries.
Table of Contents (17 chapters)
close
close
16
Index

Setting plot background colors


The default background color of all plots in R is white, which is usually the best choice as it is least distracting for data analysis. However, sometimes, we might wish to use another color. We will see how to set background colors in this recipe.

Getting ready

All you need to try out in this recipe is to run R and type the recipe in the command prompt. You can also choose to save the recipe as a script so that you can use it again later on.

How to do it...

To set the plot background color to gray, we use the bg argument in the par() command:

par(bg="gray")
plot(rnorm(100))

How it works...

The bg argument of the par() command sets the background color for the entire plotting area, including the margins for any subsequent plots on the same device. Until the plotting device is closed or a new device is initiated, the background color stays the same.

There's more...

It is more likely that we want to set the background color only for the plot region (within the axes) but...

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
R Graphs Cookbook Second Edition
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon