import numpy as np
import matplotlib.pyplot as plt
import astropy.units as u

from dust_extinction.parameter_averages import (CCM89, O94, F99, F04,
                                                VCG04, GCC09, M14, F19, D22)

fig, ax = plt.subplots()

# generate the curves and plot them
x = np.arange(0.5,11.0,0.1)/u.micron

Rv = 2.5

models = [CCM89, O94, F99, F04, VCG04, GCC09, M14, F19, D22]

for cmodel in models:
   ext_model = cmodel(Rv=Rv)
   indxs, = np.where(np.logical_and(
      x.value >= ext_model.x_range[0],
      x.value <= ext_model.x_range[1]))
   yvals = ext_model(x[indxs])
   ax.plot(x[indxs], yvals, label=ext_model.__class__.__name__)

ax.set_xlabel('$x$ [$\mu m^{-1}$]')
ax.set_ylabel('$A(x)/A(V)$')

ax.set_title('R(V) = 2.5')

ax.legend(loc='best')
plt.tight_layout()
plt.show()