Question: 2 - D Histograms A ) Download and load stars.txt in your program. Make a 2 D Histogram of Magnitude of the Stars vs

2-D Histograms
A) Download and load "stars.txt" in your program. Make a 2D Histogram of Magnitude of
the Stars vs Temperature of the Stars. Choose a 5050 bins size.
B) Change the color scale to LogNorm instead and add the colorbar to the plot and
increase the figure size to (12,8)
from matplotlib. colors import LogNorm
from pylab import colorbar, figure
C) hist2D also returns the histogram information to you in tuple form, but everything is in
2D now!
h2= hist2D(stars[:,0],stars[:,1])
pr(type(h2))
h2[0] is the NxM array of the values of the histogram.
h2[1] is the array of x bin edges
h2[2] is the array of y bin edges
The bin edges have 1 more elements than the number of bins as usual, but we can use
BinCenter to fix that. Use BinCenter to save the arrays of the Temperature Bin Center
and Magnitude Bin Center.
D)h2[0] is a 2D array so that's harder to deal with. Write a program that loops over the
y-axis (Magnitude) of h2[0] and compute the WeightedAvg for each row of x-values
(Temperature). Save these values to an array.
Plot Magnitude vs WeightedAvg Temperature you computed and overlay it with the
Histogram.
E) Noticed that your WeightedAvg goes through the top of the Histogram most in the
bulk but does NOT near the top or bottom. Explain why briefly.
stars.txt =7828.831919.67
2828.838318.78
2929.918919.17
1103.104714.19
1929.037117.29
7028.015912.08
9614.193616.92
2 - D Histograms A ) Download and load "stars.txt

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!