Skip to content

Instantly share code, notes, and snippets.

@jakevdp

jakevdp/fill_between.png

Last active Aug 29, 2015
Embed
What would you like to do?
fill_between example
import numpy as np
from matplotlib import pyplot as plt
from astroML.datasets import fetch_sdss_corrected_spectra
from astroML.datasets.tools.sdss_fits import log_OIII_Hb_NII
data = fetch_sdss_corrected_spectra()
i = np.where((data['lineindex_cln'] == 4) | (data['lineindex_cln'] == 5))
plt.scatter(data['log_NII_Ha'][i], data['log_OIII_Hb'][i],
c=data['lineindex_cln'][i], s=9, lw=0)
NII = np.linspace(-2.0, 0.35)
plt.plot(NII, log_OIII_Hb_NII(NII), '-k')
plt.plot(NII, log_OIII_Hb_NII(NII, 0.1), '--k')
plt.plot(NII, log_OIII_Hb_NII(NII, -0.1), '--k')
plt.fill_between(NII, log_OIII_Hb_NII(NII, -0.1), log_OIII_Hb_NII(NII, 0.1),
facecolor='gray', alpha=0.5, edgecolor='none')
plt.xlim(-2.0, 1.0)
plt.ylim(-1.2, 1.5)
plt.xlabel(r'$\mathrm{log([NII]/H\alpha)}$', fontsize='large')
plt.ylabel(r'$\mathrm{log([OIII]/H\beta)}$', fontsize='large')
plt.savefig('fill_between.png')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment