Ex 8 Plotting
Ex 8 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.
Then adjust the font size and type for the titles and labels, to make the chart look
as good as possible.
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.
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.
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.