library(dslabs)
## Warning: package 'dslabs' was built under R version 4.3.3
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.4.4     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.0
## ✔ 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
library(highcharter)
## Warning: package 'highcharter' was built under R version 4.3.3
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo 
## Highcharts (www.highcharts.com) is a Highsoft software product which is
## not free for commercial and Governmental use
## 
## Attaching package: 'highcharter'
## 
## The following object is masked from 'package:dslabs':
## 
##     stars
data("stars") #pulling the data
#cleaning the dataset
starsdata <- stars |> 
  select(temp, distance, bv, radiussun) |>
  filter(distance < 600)

Temperature VS Distance Scatterplot

#creating the scatterplot

stars1 <- highchart() |>
  hc_add_series(data = starsdata,
                   type = "scatter",
                   hcaes(x = temp,
                   y = distance,
                   color = bv,
                   size = radiussun)) |>
  hc_xAxis(title = list(text="Temperature")) |>
  hc_yAxis(title = list(text="Distance")) |>
  hc_title(text = "Temperature vs Distance Scatterplot") |>
  hc_legend(title = list(text = "BV"), align = "right", verticalAlign = "top") #fixing legend
stars1

In my scatter plot, I used the dataset stars from DS Labs which contained information about the properties of stars. I selected the variables temp, distance, BV, and radiussun. The temp variable lists the different temperatures of each star, and I added this as the x axis of the plot. I then made the distance variable, which lists the distance of each star, as the y axis of the plot. The colors of each point describe the BV, which is how hot or cold each star is. The sizes of the points are based on the radiussun variable, which is the radius. In this scatter plot we can see how the BV and the temperature are related, since the stars with lower bv colors have higher temperatures and vice versa. A hot star has a bv color index close to 0 or negative, while a cool star has a bv color index close to 2.0. I used highcharter in my visualization so that there would be interactivity and the x and y values and the size would display for each star.