Stellar Classification Chart
Stellar Classification Chart

[Source: NASA]

Install Data from DS Labs

library("dslabs")
data(package="dslabs")
list.files(system.file("script", package = "dslabs"))
##  [1] "make-admissions.R"                   
##  [2] "make-brca.R"                         
##  [3] "make-brexit_polls.R"                 
##  [4] "make-calificaciones.R"               
##  [5] "make-death_prob.R"                   
##  [6] "make-divorce_margarine.R"            
##  [7] "make-gapminder-rdas.R"               
##  [8] "make-greenhouse_gases.R"             
##  [9] "make-historic_co2.R"                 
## [10] "make-mice_weights.R"                 
## [11] "make-mnist_127.R"                    
## [12] "make-mnist_27.R"                     
## [13] "make-movielens.R"                    
## [14] "make-murders-rda.R"                  
## [15] "make-na_example-rda.R"               
## [16] "make-nyc_regents_scores.R"           
## [17] "make-olive.R"                        
## [18] "make-outlier_example.R"              
## [19] "make-polls_2008.R"                   
## [20] "make-polls_us_election_2016.R"       
## [21] "make-pr_death_counts.R"              
## [22] "make-reported_heights-rda.R"         
## [23] "make-research_funding_rates.R"       
## [24] "make-stars.R"                        
## [25] "make-temp_carbon.R"                  
## [26] "make-tissue-gene-expression.R"       
## [27] "make-trump_tweets.R"                 
## [28] "make-weekly_us_contagious_diseases.R"
## [29] "save-gapminder-example-csv.R"

Picked data = “stars”

data("stars")
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.0     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors

Creating visualization plot

Highcharter plot

library(highcharter)
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
## 
##  次のパッケージを付け加えます: 'highcharter'
##  以下のオブジェクトは '.GlobalEnv' によってマスクされています:
## 
##     stars
##  以下のオブジェクトは 'package:dslabs' からマスクされています:
## 
##     stars
library(RColorBrewer)

top_50_rows <- head(stars, 50) #Get top 50 rows data

plot1 <- highchart() |>
  hc_title(text = "Comparison of Star Temperature and Magnitude",  # Main title
           useHTML = TRUE) |>  # Allow HTML formatting (optional)
  hc_subtitle(text = "Top 50 Stars (dslabs: stars)",  # Subtitle
             align = "right") |>
  hc_add_series(data = top_50_rows, # Creating scatter plot
                type = "scatter",  # Using "scatter"
                hcaes(x = magnitude, y = temp, group = type)) |>

  hc_xAxis(title = list(text = "Magnitude")) |> #x axes title
  hc_yAxis(title = list(text = "Temperature")) |>  #y axes title
  hc_plotOptions(series = list(marker = list(symbol = "circle"))) |> #Set all plot circle
  hc_tooltip(shared = TRUE,
             borderColor = "pink",
             pointFormat = "Star: {point.star}<br>Magnitude: {point.magnitude}:<br>Temp:   {point.temp}<br>") |>  # Orgnize tooltip detail
  hc_legend(align = "right",
            verticalAlign = "top", 
            title = list(text = "Star Type"))  #set legend place on top of right align

plot1

Since I selected the source of a star from dslabs, I created a plot that seems like a starry sky. The visualization describes the top 50 stars, evaluating their surface temperatures and the magnitude (apparent brightness of a celestial object as seen from Earth). I used Highcharts to create a scatter plot, wherein a circle represents every star. To distinguish among different star types, the facts factors are segmented by using shade. My primary purpose was to equip the plot with informative tooltips that could seem to hover over an information factor. On the begging, as I was first of all considering using ggplot2 for this project, it became apparent that controlling the order of tooltips wasn’t simply workable within that framework. Thus, Highcharts, presented the level of customization required to control tooltip presentation efficaciously. This flexibility allowed me to tailor the audience experience by making sure tooltips show vital information like star name, temperature, and magnitude clearly and organized. Overall, using Highcharts, I was able to create a visually compelling and informative representation of the stars, facilitating a deeper exploration of their traits. In addition, at the end of each code, I briefly describe what and how I programmed it, so the viewer will be able to understand this code by following it line by line.

? Star type - stellar classification is the classification of stars based on their spectral characteristics.