You are on page 1of 14

DATA VISULIZATION LAB ASSIGNMENT 2

NAME: NIMISHA JHA


REGISTRATON NUMBER:18BCE2420
SLOT: L27+L28

Create a scatter plot with product on the x axis and Amount on the y axis.
Code:
> library(ggplot2)
> mydata <- read.csv("C:/Users/Das/Desktop/file_imp/data_Visualiz/
fruits.csv")
> mydata

> ggplot(mydata, aes(x = Product, y = Amount)) +


+ geom_point() Result :
Color the points blue.
Code :
> ggplot(mydata, aes(x = Product, y = Amount)) +
+ geom_point(color = "blue")

Result :
Create the histogram and box plot by taking the necessary attribute.
Code:
> ggplot(mydata, aes(x=Amount)) + geom_histogram(colour="red", fill="grey")

Result:
Code:
> p10 <- ggplot(mydata, aes(x = Country, y = Amount)) +
+ geom_boxplot()
> p10

Result:
Map the color of the the points to region.
Code:
> ggplot(mydata, aes(x = Product, y = Amount)) +
+ geom_point(aes(color = Product))

Result:
Make the points bigger by setting size to 2 Code:
> ggplot(mydata, aes(x = Product, y = Amount)) +
+ geom_point(aes(color = Product),size = 2)

Result:
Recreate a scatter plot with amount on the x axis and product on the y axis.
Code:
> ggplot(mydata, aes(y = Product, x = Amount)) +
+ geom_point(aes(color = Product),size = 2)

Result:

Overlay a smoothing line on top of the scatter plot using geom_smooth Code:
> ggplot(mydata, aes(x=Product, y= Amount)) +
+ geom_point() +
+ geom_smooth(span = 0.1)

Result:
K MEANS CLUSTERING - 1ST AUGUST
Question 1:
Code :
Result:

You might also like