#I installed dslabs using the code directly from the lesson this week.library("dslabs")data(package="dslabs")list.files(system.file("script", package ="dslabs"))
#I chose to make a scatter plot with the dots colored according to their star type. ggplot(stars,aes(x=temp,y=magnitude,color=type))+#I added my pointsgeom_point(alpha=0.7, size=2)+#And then reversed my x axis because that is the layout on a H-R Diagram and I thought it would be neat to make it resemble onescale_x_reverse()+#I originally used Set 1 but when I used that, my O type star was assigned a white dot on a white background where it was not visible or it was just too many points and was not assigned a color, so I changed it to Spectral which I found from googling the color brewer sets.scale_color_brewer(name="Star Type", palette ="Spectral")+#I added my labelslabs(title="Star Temp vs Brightness by Star Type",x="Temp (Kelvin)",y="Magnitude (Brightness)",caption="Source: Stars dataset from dslabs" )+#Here is where I changed my background.theme_minimal()+theme(plot.background =element_rect(fill ="gray"),panel.background =element_rect(fill ="gray"),panel.grid =element_line(color ="white"),text =element_text(color ="white"),axis.text =element_text(color ="white") )
I chose the stars data set because I love astronomy and after looking at the variables, I thought I could make a cool graph that would resemble a H-R diagram. I started by setting up my scatter plot and reversing the x-axis because that is how the H-R Diagram is set up. I labeled my axes, for my x assumed it was in kelvin and for magnitude I assumed it was the absolute magnitude. I finally edited it to make sure it had fun colors and was easy to see, I had to look up color palettes because I had a larger data set but I found one that worked.