I am wanting to create graphs of spectral radiance ($B_\lambda(\lambda, T)$) against wavelength ($\lambda$) of a black body of temperature $T \text{ K}$ using Planck's Law. However, I don't know what the maximum and minimum wavelengths should be.

I've tried rearranging the Planck's Law equation for the wavelength where the $B_\lambda(\lambda, T) = 0.1$, but it's too complex.

So, what should I do to fit the majority of the curve nicely to the graph?

  • 2
    $\begingroup$ LPT: when you don't know the range to plot, use an iterative process (i.e., start with 1e-9 and 1e+9 and then expand or contract as necessary). $\endgroup$
    – Kyle Kanos
    Aug 28, 2017 at 12:22

2 Answers 2


The Wien displacement law tells you what the peak wavelength is:


Where b = $2.897\cdot 10^{-3}~\rm{m\cdot K}$

You could start at a wavelength that is 0.1 of that, and go until a wavelength that is 100x that. If you use logarithmic scales, you will get "pretty much everything" you want. Here is a piece of code to demonstrate (Python):

from scipy.constants import codata
import numpy as np
import matplotlib.pyplot as plt

D = codata.physical_constants

h = D['Planck constant'][0]
k = D['Boltzmann constant'][0]
c = D['speed of light in vacuum'][0]
wienConstant = 2.897e-3

def planck(T, l):
    # calculate the Planck Law for a specific temperature and an array of wavelengths
    p = c*h/(k*l*T)
    result = np.zeros(np.shape(l))+1e-99
    # prevent underflow - compute only when p is "not too big"
    calcMe = np.where(p<700)
    result[calcMe] = (h*c*c)/(np.power(l[calcMe], 5.0) * (np.exp(p[calcMe])-1))        
    return result

# compute for a range of temperatures
Tbody=np.arange(2000, 12000, 2000)

Lpeak = wienConstant / Tbody

plot1 = plt.figure()
ax = plot1.add_subplot(111)

# compute Planck function for a range of wavelengths and temperatures:
for ti,T in enumerate(Tbody):
    # wavelengths used: from 0.1 * peak to 100* peak
    Lvec = np.logspace(-1, 2, 500) * Lpeak[ti]  # wavelengths: 1 nm - 1 mm
    r = planck(T, Lvec)
    ax.plot(Lvec*1e9, r, label='T=%d'%T)

# create axes and labels
plotAs = 'linear' # set to 'log' for log plot
ax.set_xlabel('lambda (nm)')  
ax.set_ylabel('radiance (W/sr/m^3)')
ax.set_title('Black body spectrum')
ax.set_ylim (1e-8, 2.5e14)


And the resulting plot:

enter image description here

Actually, if you use a linear plot you will find that a range of 0.1x to 10x is plenty:

enter image description here

Play with that, and optimize for your needs.

Incidentally - on a log scale, the shape of the function is identical for different values of T - the curve is just scaled vertically, and shifted horizontally. This is why a simple scaling of the limits relative to the peak works well.


While Kyle Kanos gives a useful tip in comments, of just iteratively changing the range until you're satisfied, it's possible you may want to systematically create a good graph. My suggestion: use the limit behaviour of the black body distribution.

Large Wavelength For large wavelength, thermal radiation is approximated by the Rayleigh-Jeans tail, given by the formula: $$B(\lambda) = \frac{2 c k_B T}{\lambda ^4}$$ You can use this to find the cut-off wavelength.

Short Wavelength Thermal radiation is described by Wien's approximation, at short wavelength, with the formula: $$B(\lambda) = \frac{2 h c^2}{\lambda ^5} e^{-\frac{h c}{\lambda k_B T}}$$

  • $\begingroup$ 0 would be a bad limit because $1/0\equiv\rm undefined$. $\endgroup$
    – Kyle Kanos
    Aug 28, 2017 at 16:18
  • $\begingroup$ @KyleKanos true, fixed. Was thinking of the limit behaviour. $\endgroup$
    – CDCM
    Aug 29, 2017 at 1:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.