SDSS Galaxy Colors¶
The function fetch_sdss_galaxy_colors()
used below actually queries
the SDSS CASjobs server for the colors of the 50,000 galaxies. Below we
extract the and colors for 5000 objects, and
scatter-plot the results.
# Author: Jake VanderPlas <vanderplas@astro.washington.edu>
# License: BSD
# The figure is an example from astroML: see http://astroML.github.com
from matplotlib import pyplot as plt
from astroML.datasets import fetch_sdss_galaxy_colors
#------------------------------------------------------------
# Download data
data = fetch_sdss_galaxy_colors()
data = data[::10] # truncate for plotting
# Extract colors and spectral class
ug = data['u'] - data['g']
gr = data['g'] - data['r']
spec_class = data['specClass']
galaxies = (spec_class == 'GALAXY')
qsos = (spec_class == 'QSO')
#------------------------------------------------------------
# Prepare plot
fig = plt.figure()
ax = fig.add_subplot(111)
ax.set_xlim(-0.5, 2.5)
ax.set_ylim(-0.5, 1.5)
ax.plot(ug[galaxies], gr[galaxies], '.', ms=4, c='b', label='galaxies')
ax.plot(ug[qsos], gr[qsos], '.', ms=4, c='r', label='qsos')
ax.legend(loc=2)
ax.set_xlabel('$u-g$')
ax.set_ylabel('$g-r$')
plt.show()