── 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.1 ✔ tibble 3.2.1
✔ lubridate 1.9.4 ✔ 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
library(ggthemes)
Warning: package 'ggthemes' was built under R version 4.4.3
library(ggrepel)
Warning: package 'ggrepel' was built under R version 4.4.3
library(ggplot2)
Printing out the variables and observations of stars
head(stars)
star magnitude temp type
1 Sun 4.8 5840 G
2 SiriusA 1.4 9620 A
3 Canopus -3.1 7400 F
4 Arcturus -0.4 4590 K
5 AlphaCentauriA 4.3 5840 G
6 Vega 0.5 9900 A
Code for the Scatter Plot visualization of Properties of Stars
star magnitude temp type
1 Sun 4.8 5840 G
2 SiriusA 1.4 9620 A
3 Canopus -3.1 7400 F
4 Arcturus -0.4 4590 K
5 AlphaCentauriA 4.3 5840 G
6 Vega 0.5 9900 A
7 Capella -0.6 5150 G
8 Rigel -7.2 12140 B
9 ProcyonA 2.6 6580 F
10 Achemar -2.4 20500 B
11 Hadar -5.3 25500 B
12 Altair 2.2 8060 A
13 Aldebaran -0.8 4130 K
14 Spica -3.4 25500 B
15 Fomalhaut 2.0 9060 A
16 Pollux 1.0 4900 K
17 Deneb -7.2 9340 A
18 BetaCrucis -4.7 28000 B
19 Regulus -0.8 13260 B
20 Acrux -4.0 28000 B
21 Adhara -5.2 23000 B
22 Shaula -3.4 25500 B
23 Bellatrix -4.3 23000 B
24 Castor 1.2 9620 A
25 BetaCentauri -5.1 25500 B
26 AlphaCentauriB 5.8 4730 K
27 AlNa'ir -1.1 15550 B
28 Miaplacidus -0.6 9300 A
29 Elnath -1.6 12400 B
30 Alnilam -6.2 26950 B
31 Mirfak -4.6 7700 F
32 Alnitak -5.9 33600 O
33 Dubhe 0.2 4900 K
34 Alioth 0.4 9900 A
35 Peacock -2.3 20500 B
36 KausAustralis -0.3 11000 B
37 ThetaScorpii -5.6 7400 F
38 Atria -0.1 4590 K
39 Alkaid -1.7 20500 B
40 AlphaCrucisB -3.3 20500 B
41 Avior -2.1 4900 K
42 DeltaCanisMajoris -8.0 6100 F
43 Alhena 0.0 9900 A
44 Menkalinan 0.6 9340 A
45 Polaris -4.6 6100 F
46 Mirzam -4.8 25500 B
47 DeltaVulpeculae 0.6 9900 A
48 *AlphaCentauriB 5.8 4900 K
49 *SiriusA 1.4 9620 A
50 *SiriusB 11.2 14800 DA
51 EpsilonEridani 6.1 4590 K
52 EpsilonIndi 7.0 4130 K
53 *61CygniA 7.6 4130 K
54 TauCeti 5.7 5150 G
55 *ProcyonA 2.6 6600 F
56 *ProcyonB 13.0 9700 DF
57 vanMaanen'sStar 14.2 13000 DB
58 Altair 2.2 8060 A
59 *40EridaniA 6.0 4900 K
60 *40EridaniB 11.1 10000 DA
61 *70OphiuchiA 5.8 4950 K
star_df <-#options(repr.plot.width =20, repr.plot.height =12)ggplot(stars_update, aes(x = temp, y =-(magnitude), color = temp, size =-(magnitude), label = star )) +geom_point( aes(shape ="temp")) +scale_shape_manual(values =c("temp"="*" ))+geom_text_repel(nudge_x =0.00008, color ="white", size =2) +# Customize theme to no lines and black backgroundscale_color_gradientn(colors =c("red","orange","yellow","white","lightblue","cornflowerblue")) +theme_classic()+theme(panel.background =element_rect(fill ='black'))+#Titles, labels, etclabs(x ="Temperature(K)", y ="Absolute Magnitude",title ="Physical Properties of Stars" ) +#Changes the size and font of the titles and axestheme(plot.title =element_text(family ="mono", size =20, color ="Blue"),axis.title.x =element_text(family ="mono", size =10, color ="Blue"),axis.title.y =element_text(family ="mono", size =10, color ="Blue") )star_df
Warning: ggrepel: 12 unlabeled data points (too many overlaps). Consider
increasing max.overlaps
Summary
This scatter-plot is about the Physical Properties of stars, specifically how temperature and absolute magnitude illuminates stars to the human eye. In the stars data set the minimum temperature in Kelvin is 3276.674, and max is 14632.835K For the x-axis, I did the temperatures of the stars. The colors I picked as specific to the colors of actual stars. Ranging from red - dark blue. In addition to that the y-axis consists of the absolute magnitude of the stars. This measures the brightness of stars at a standard distance. Lastly Luminosity of a star compares the energy output of a star to the sun(the sun is Earths brightest star). So based on this graph, we can see that lower temperature stars are red, and higher temperature stars are blue. Stars at a lower magnitude are more visible to the human eye, while higher ones are less visible. That is why red stars are smaller on the graph, because lower temperature omit less light than stars have higher temperatures.
Overall, this was a graph/data-set that was really fun to work with, and I am proud that I was able to show exactly what I was looking for.
##Sources:
How I changed the shape to stars: https://masteringr.com/ggplot2/how-to-change-point-shapes-in-ggplot2/
How I learned to remove lines/ change background color: https://www.statology.org/ggplot-background-color/
How I learned about gradientn(gradientn helped me produce the gradient in the order that I wanted it): https://ggplot2-book.org/scales-colour.html