Professional Documents
Culture Documents
20mid0209 Assessment - 4
20mid0209 Assessment - 4
LAB ASSIGNMNET – 4
Scalar visualization - 2
#Dataset Preparation:
device_type <- c("Laptop", "Smartphone", "Tablet", "Laptop", "Smartphone",
"Tablet", "Laptop", "Smartphone", "Tablet", "Laptop", "Smartphone", "Tablet",
"Laptop", "Smartphone", "Tablet", "Laptop", "Smartphone", "Tablet",
"Laptop", "Smartphone")
os <- c("Windows", "Android", "iOS", "Windows", "Android", "iOS", "MacOS",
"Android", "iOS", "Windows", "Android", "iOS", "MacOS", "Android", "iOS",
"Windows", "Android", "iOS", "MacOS", "Android")
cpu_cores <- c(4, 2, 4, 4, 2, 4, 4, 2, 4, 4, 2, 4, 4, 2, 4, 4, 2, 4, 4, 2)
software_apps <- c(20, 10, 15, 25, 15, 20, 30, 20, 25, 20, 15, 10, 25, 20, 30, 20,
25, 20, 15, 10)
battery_life <- c(5, 6, 7, 5, 6, 7, 4, 5, 6, 4, 5, 6, 3, 4, 5, 3, 4, 5, 3, 4)
processor_clock_speed <- c(2.5, 1.8, 2.2, 2.7, 2.0, 2.4, 2.9, 2.2, 2.6, 3.0, 2.4, 2.8,
3.2, 2.6, 3.0, 3.4, 2.8, 3.2, 3.6, 3.0)
df <- data.frame(device_type, os, cpu_cores, software_apps, battery_life,
processor_clock_speed)
print(df)
# code
#Output
ATTRIBUTE TYPE:
Independent Variables:
• Device type
• Operating System (OS)
• CPU cores
• Software apps
1. Histogram:
install.packages("ggplot2")
library(ggplot2)
ggplot(df, aes(x=processor_clock_speed)) +
geom_histogram(binwidth=0.2, color="black", fill="khaki")
+
ggtitle("Processor Clock Speed Histogram") +
xlab("Processor Clock Speed (GHz)") +
ylab("Frequency")
Inference:
From the histogram plot, we can see that the processor clock speed for
Smartphones and Laptops is higher compared to Tablet. This could indicate
that Smartphones and Laptops are designed using the frequency.
2) Color mapping:
Code:
ggplot(df, aes(x=os, y=device_type, fill=processor_clock_speed)) +
geom_tile(color="white", size=0.2) +
scale_fill_gradient(low="white", high="blue") +
labs(title="Processor Clock Speed by Device Type and OS",
x="Operating System", y="Device Type", fill="Processor Clock
Speed")
Graph:
Inference:
From the heat map plot, we can see that the operating system for
checking the processor clock speed for the devices such has smart
phone, laptop and tablet , where it has compared with blue colour
which represents max level and light blue colour which represents
the low level.
Zebra Color map:
Code:
zebra_colors <- colorRampPalette(c("white", "black"))(100)
ggplot(data.frame(processor_clock_speed), aes(x = 1, y =
processor_clock_speed)) +
geom_tile(aes(fill = processor_clock_speed), color = "white") +
scale_fill_gradientn(colors = zebra_colors) +
scale_x_continuous(limits = c(0.5, 1.5), expand = c(0, 0)) +
scale_y_continuous(limits = c(min(processor_clock_speed),
max(processor_clock_speed)), expand = c(0, 0)) +
labs(x = NULL, y = "Processor Clock Speed", fill = "Processor
Clock Speed") +
theme_void()
Graph:
Inference:
In these plot, we can see the black and white colour for the processor
clock speed. Where the black color represents frequent number of
appearance and white color represents the low number of appearance
of the devices used.
Code:
Gray scale:
Code:
library(ggplot2)
library(dplyr)
# Create a new column with the total count of each device type
data <- data %>% group_by(device_type) %>% mutate(total_count = n())
Graph:
Inference:
In this grayscale plot, we can able to predict the percentage of each device types
used frequently. In these graph we can see that Tablet is frequently used device
and laptop and smartphones have equal numbers.
Texture -based:
Code:
install.packages("raster")
library(raster)
# Set the values of the raster object to the battery life data
values(r) <- matrix(battery_life, ncol=5)
Contours:
Code:
# Load required libraries
library(ggplot2)
library(dplyr)
Inference:
In this plot, we can represent the processor clock speed and the battery life of
the devices. Where the violet colour represents the maximum level of the
battery life and where the red colour represents the low level of the battery life
for all the devices.
3. Prepare a Gantt chart for depicting the weekly tasks for
Advanced Data Visualization lab.
Code:
Inference:
In these antt chart we can able to see the different target represent
different colours and the duration for 4 months represents in these
chart and number of task represents with the colours.