Stars

Introduction

I will be using the stars data set from the DSlabs package. It consists of 2 categorical variables and 2 quantitative variables, including the type of star it is, the temperature, and the magnitude. In this document I will be using code to create a visualization that presents the relationship between the type of star and it’s temperature and magnitude.

First off install the appropriate packages

library("dslabs")
Warning: package 'dslabs' was built under R version 4.5.3
library(ggfortify)
Loading required package: ggplot2
data(package="dslabs")

Then load in the stars data set

data("stars")

Create a graph assigning each variable properly

ggplot(stars, aes(x=type, y=temp, color=magnitude)) +
  geom_point(alpha = .9) +
  scale_color_gradient(low = "blue", high = "red")

Looking a little bland? Let’s add proper titles and themes

ggplot(stars, aes(x=type, y=temp, color=magnitude)) +   
 geom_point(alpha = .9) +   scale_color_gradient(low = "blue", high = "red") +
  labs(
    title = "Correlation between the magnitude and temperature of stars",
     x = "Type of star",
     y = "Temperature in °F",
     color = "Magnitude",
     caption = "*Dataset from DSlabs") + 
  theme_minimal(base_size = 12)

Conclusion

In this document, I focused on using simple yet effective methods of displaying data, with that consisting of heat bar being used to show off the magnitude. I went with the basic approach utilizing the x and y axis; something I wish I would’ve done differently is adding an interactive feature so the viewer can see the name of the star over the dot. The visualization represents how the higher the magnitude a star is, the lower in temperature it would be, and type M consisted of the most high magnitude/low temp stars.