-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCapstone_Part2.py
More file actions
62 lines (49 loc) · 1.67 KB
/
Capstone_Part2.py
File metadata and controls
62 lines (49 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Author: Jake VanderPlas <vanderplas@astro.washington.edu>
# License: BSD
# The figure is an example from astroML: see http://astroML.github.com
import numpy as np
from matplotlib import pyplot as plt
from astroML.datasets import fetch_imaging_sample
#------------------------------------------------------------
# Get the star/galaxy data
data = fetch_imaging_sample()
objtype = data['type']
stars = data[objtype == 6][:5000]
galaxies = data[objtype == 3][:5000]
#------------------------------------------------------------
# Plot the stars and galaxies
plot_kwargs = dict(color='k', linestyle='none', marker='.', markersize=1)
fig = plt.figure()
ax1 = fig.add_subplot(221)
ax1.plot(galaxies['gRaw'] - galaxies['rRaw'],
galaxies['rRaw'],
**plot_kwargs)
ax2 = fig.add_subplot(223, sharex=ax1)
ax2.plot(galaxies['gRaw'] - galaxies['rRaw'],
galaxies['rRaw'] - galaxies['iRaw'],
**plot_kwargs)
ax3 = fig.add_subplot(222, sharey=ax1)
ax3.plot(stars['gRaw'] - stars['rRaw'],
stars['rRaw'],
**plot_kwargs)
ax4 = fig.add_subplot(224, sharex=ax3, sharey=ax2)
ax4.plot(stars['gRaw'] - stars['rRaw'],
stars['rRaw'] - stars['iRaw'],
**plot_kwargs)
# set labels and titles
ax1.set_ylabel('$r$')
ax2.set_ylabel('$r-i$')
ax2.set_xlabel('$g-r$')
ax4.set_xlabel('$g-r$')
ax1.set_title('Galaxies')
ax3.set_title('Stars')
# set axis limits
ax2.set_xlim(-0.5, 3)
ax3.set_ylim(22.5, 14)
ax4.set_xlim(-0.5, 3)
ax4.set_ylim(-1, 2)
# adjust tick spacings on all axes
for ax in (ax1, ax2, ax3, ax4):
ax.xaxis.set_major_locator(plt.MultipleLocator(1))
ax.yaxis.set_major_locator(plt.MultipleLocator(1))
plt.savefig('capstone_part2.png')