Commit 18b7c53553841f39d3192515f1f54c04198d2866

Authored by Jürgen Knödlseder
1 parent 9502ac30

Change show_irf.py so that it is also compliant with older matplotlib versions

Showing 1 changed file with 15 additions and 4 deletions
examples/show_irf.py
... ... @@ -205,7 +205,6 @@ def plot_psf(sub, psf, emin=None, emax=None, tmin=None, tmax=None,
205 205 cbar = plt.colorbar(c, orientation='horizontal', shrink=0.8)
206 206 tick_locator = ticker.MaxNLocator(nbins=5)
207 207 cbar.locator = tick_locator
208   - cbar.update_ticks()
209 208 cbar.set_label('arcmin')
210 209  
211 210 # Show boundary contours
... ... @@ -339,7 +338,6 @@ def plot_edisp(sub, edisp, emin=None, emax=None, tmin=None, tmax=None,
339 338 cbar1 = plt.colorbar(c1, orientation='horizontal', shrink=0.8)
340 339 tick_locator = ticker.MaxNLocator(nbins=5)
341 340 cbar1.locator = tick_locator
342   - cbar1.update_ticks()
343 341 cbar1.set_label('E$_{reco}$ / E$_{true}$')
344 342  
345 343 # Show boundary contours
... ... @@ -359,7 +357,6 @@ def plot_edisp(sub, edisp, emin=None, emax=None, tmin=None, tmax=None,
359 357 cbar2 = plt.colorbar(c2, orientation='horizontal', shrink=0.8)
360 358 tick_locator = ticker.MaxNLocator(nbins=5)
361 359 cbar2.locator = tick_locator
362   - cbar2.update_ticks()
363 360 cbar2.set_label('E$_{reco}$ / E$_{true}$')
364 361  
365 362 # Show boundary contours
... ... @@ -427,6 +424,8 @@ def plot_bkg(sub, bkg, emin=None, emax=None, tmin=None, tmax=None,
427 424 thetas = [tmax-i*dtheta for i in range(nthetas)]
428 425  
429 426 # Initialise image
  427 + vmin = None
  428 + vmax = None
430 429 image = []
431 430  
432 431 # Loop over offset angles
... ... @@ -448,11 +447,23 @@ def plot_bkg(sub, bkg, emin=None, emax=None, tmin=None, tmax=None,
448 447 # Append value
449 448 row.append(value)
450 449  
  450 + # Set minimum and maximum
  451 + if value > 0.0:
  452 + if vmin == None:
  453 + vmin = value
  454 + elif value < vmin:
  455 + vmin = value
  456 + if vmax == None:
  457 + vmax = value
  458 + elif value > vmax:
  459 + vmax = value
  460 +
451 461 # Append row
452 462 image.append(row)
453 463  
454 464 # Plot image
455   - c = sub.imshow(image, extent=[emin,emax,tmin,tmax], aspect=0.5, norm=LogNorm())
  465 + c = sub.imshow(image, extent=[emin,emax,tmin,tmax], aspect=0.5,
  466 + vmin=vmin, vmax=vmax, norm=LogNorm())
456 467 cbar = plt.colorbar(c, orientation='horizontal', shrink=0.8)
457 468 cbar.set_label('s$^{-1}$ MeV$^{-1}$ sr$^{-1}$')
458 469  
... ...