0% found this document useful (0 votes)
54 views

Ex 8 Plotting

The document provides instructions for creating 19 different charts and plots using various datasets. The instructions demonstrate how to create scatter plots, line charts, bar charts, histograms, density plots, pie charts, polygon charts, box plots and violin plots. Various formatting options are explored such as adding titles, labels, legends, adjusting colors, sizes, and styles.

Uploaded by

girish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views

Ex 8 Plotting

The document provides instructions for creating 19 different charts and plots using various datasets. The instructions demonstrate how to create scatter plots, line charts, bar charts, histograms, density plots, pie charts, polygon charts, box plots and violin plots. Various formatting options are explored such as adding titles, labels, legends, adjusting colors, sizes, and styles.

Uploaded by

girish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Plotting

Practice

1. Create a data frame using the carsales.csv file, then create separate vectors with
the values in the variables price and engine. Create a scatterplot that represents
the relationship between engine size and price.

2. In the scatterplot created at #1 perform the following operations:

- add a title: “Engine Size vs. Price”


- add axes labels: Engine Size (cubic inches) and Price (thousands of dollars)
- add a subtitle: “Data for 155 Car Models”

Then adjust the font size and type for the titles and labels, to make the chart look
as good as possible.

3. In the scatterplot created at #1 perform the following operations:

- change the dots color to dark orange


- change the dots shape to a reversed rectangle
- make the dots size 50% bigger
- change the background color to moccasin

4. Add a trend line to the scatterplot created at #1.

5. Create a data frame using the phone.csv file, then create separate vectors with
the values in the variables tenure and income. Next, create a factor out of the
variable churn. Finally, build a clustered scatterplot that represents the
relationship between tenure and income for each churn category (0 and 1). Add a
legend to the chart.

6. Add a legend to the chart created at #5.


7. Create a data frame using the stocks.csv file, then create separate vectors with
the values in the variables month and high. Then represent the evolution of the
stocks at the high point (variable high) in the last 20 months, using a line chart.

8. In the chart created at #5, add a title and axes labels, then make the line three
times thicker and set the line type to twodash.

9. Using the same data as in the exercise #7, create a chart that over plots lines
and dots. Make the line type dotdash and the dot type a diamond.

10. Create another vector that contains the values in the variable low, than represent
the evolution of the stocks at both the high and low points, using a chart type with
two lines. Add a legend to the chart.

11. Create a vector with the name of four friends: John, Paul, Linda and Barbara,
then a vector that stores their annual salary: 72000, 55000, 69000, 43000. Next,
create a bar chart that represents each person’s salary. Add a title and axis
labels to the chart.

12. In the chart created at #11 do the following:

- color each bar in a different color


- change the border color of the bars to navyblue
- make the bars wider
- make the bars thinner

13. Create a data frame using the phone.csv file, and then create a vector with the
values in the variable tenure. Afterwards build a histogram for this vector. On the
y axis you should represent the percentages.

14. In the chart created at #13 add a title, change the bar color to firebrick3 and
change the number of bars to 15.

15. Create a data frame using the phone.csv file, then create separate vectors with
the values in the variables tenure and income. Next, create a chart that
represents the density lines of these vectors. Make the line 130% thicker than the
default, and make them dotted.
16. Using the vectors created at #11, build a pie chart that represents the annual
salaries. Add a title to the chart, then add labels, as well as percentages.

17. With the same data as in the exercise above, create a polygon chart instead of a
pie chart.

18. Create a data frame using the phone.csv file, then create a vector with the values
in the variables tenure and churn. Next, create a boxplot chart that represents the
distribution of the variable tenure for each churn category (0 and 1). Make the
boxes of different colors.

19. With the same data as in the exercise above, create a violin chart.

You might also like