Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Question: What do the empty cells in plot with facet_grid(drv ~ cyl) mean?

How do this plot is


related to the below plot (refer figure-2)? [2 marks]

ggplot(data = mpg) + geom_point(mapping = aes(x = hwy, y = cty)) + facet_grid(drv ~ cyl)

ggplot(data = mpg) + geom_point(mapping = aes(x = drv, y = cyl))

Figure: 2

Answer: Blank cell in the figure 1 represents that there is no observation (or cars) with the particular
combination of drv (n-wheel drive) and cyl (number of cylinders). For example, 4-wheel drive (drv)
and 5-cyl (5 cylinderical).

Figure 2 represents the plot between drv and cyl, and points are plotted at the intersection of the
axes. These points (of figure 2) are represented as cells in figure 1. Further, the intersections without
a point in figure 2 are the empty cells in figure 1.

Full marks awarded to those who have explained the figures, and the relationship between figures.
Question. Figure 1 plots three continuous variables, x, y, and z. There is a line at x = 2 which
separates the points.
Figure 2 consists of two plots. The first plot between x and z variables. The second plot between x
and y variables.

Which plots (or figure) would be easy to comprehend? Why? (Upto 100 words)

Answer:

Figure 2 is easier to comprehend than figure 1. Because humans are not good at reading the 3D-
graphs. Figure 1 is creating an illusion that all orange points are placed after the x=2 line whereas
figure 2 shows that a few orange points are situated located before the x=2 line. Figure-1 is
misleading the viewers/analyst. While figure-2 helps the analyst to clearly understand the issue or
scenario.

Note: The above explanation does not mean that 3D-plot is an example of bad visualization but we
must understand when and where we should use 3D-plot.

Full marks awarded to those who have explained the reason why figure 2 is better than figure 1.
Question: Complete the code which creates the below graph. The data used to draw the below
graph is mpg.

Description of mpg dataset.

Code:
mpg %>% ggplot____________________

Answer: ggplot(data=mpg, mapping=aes(x=displ,y=hwy))+


geom_point()+
geom_smooth(se =FALSE)

Question:

Can we visualize more than 3-dimensional data in a 2-D chart?

If yes, then explain how 3-Dimensional data can be visualized. If No, then why?
(Word limit: upto 150 words)

Answer: Yes, we can visualize more than 3-dimensional data with the help of visual elements, such
as shape, size, color, hue, shade, values, and orientation. Faceting is also another technique to
visualize the high-dimensional data.

The below example is visualizing the 4-dimensional data into 2-dimensional chart.

First dimension – X-axis


Second dimension – Y-axis
Third dimension – Size
Fourth dimension - Hue

Observation: A large chunk of students explained the dimension reduction process but the question
was related to the visualization of 3D-data.

Full marks awarded to those who have mentioned more than 3 visual elements, or those who have
mentioned about at least 2 variables and faceting techniques.

2 marks awarded for mentioning at least two visual elements or 1 visual element with the faceting
technique.

1.5 marks awarded to those who have mentioned mathematical techniques to either transform the
data or reduce the dimension of the data.

1 mark awarded to those who have written poor explanation.

Question: Recreate the code for the below graph: (3 Marks)


Descrip_on of the mtcar dataset.
"am" attribute denotes the transmission of the vehicle.("Automatic Transmission" or "Manual
Transmission")

Code: mtcars %>%


ggplot__________________________________
Answer: Anyone of the below code:

mtcars %>% ggplot() +


geom_point(aes(mtcars$mpg, mtcars$hp, col = am)) +
facet_grid(am ~ cyl)

OR

mtcars %>% ggplot() +


geom_point(aes(mtcars$mpg, mtcars$hp, col = am)) +
facet_grid(am ~ cyl) +
xlab("Miles per gallon") +
ylab("Horse Power (hp)")

You might also like