While basic visualizations like bar charts and scatter plots are excellent for straightforward data representation, complex visualizations offer a more nuanced and in-depth look at your data. These advanced techniques allow you to explore multiple dimensions, relationships, and temporal changes in your dataset. They can include facets, interactive elements, and even animations to make your data come alive. In this section, we will explore some of these complex visualization methods using the mtcars
dataset, aiming to provide you with the tools to create more insightful and interactive data stories
library(ggplot2)
ggplot(mtcars, aes(x=factor(cyl))) +
geom_bar() +
facet_wrap(~gear) +
xlab("Number of Cylinders") +
ylab("Frequency")
ggplot(mtcars, aes(x=factor(cyl))) +
geom_bar(fill="blue", color="black") +
facet_wrap(~gear) +
xlab("Number of Cylinders") +
ylab("Frequency") +
theme_minimal()
library(plotly)
fig <- plot_ly(mtcars, x = ~hp, y = ~mpg, type = 'scatter', mode = 'markers')
fig
fig <- plot_ly(mtcars, x = ~hp, y = ~mpg, type = 'scatter', mode = 'markers') %>%
layout(title = "Customized Interactive Scatter Plot")
fig
library(heatmaply)
heatmaply(cor(mtcars),
main = "Correlation Heatmap",
xlab = "Features",
ylab = "Features")
heatmaply(cor(mtcars),
main = "Customized Correlation Heatmap",
xlab = "Features",
ylab = "Features",
colors = heat.colors(256))
library(scatterplot3d)
scatterplot3d(mtcars$hp, mtcars$mpg, mtcars$wt,
main="3D Scatter Plot")
scatterplot3d(mtcars$hp, mtcars$mpg, mtcars$wt,
main="Customized 3D Scatter Plot",
color="blue",
pch=19,
type="h")
These examples showcase how you can create more complex visualizations using the mtcars
dataset. These complex charts can provide deeper insights and are particularly useful when you have multi-dimensional data or when you want to create more interactive visual experiences.