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,7 +205,6 @@ def plot_psf(sub, psf, emin=None, emax=None, tmin=None, tmax=None,
205 cbar = plt.colorbar(c, orientation='horizontal', shrink=0.8) 205 cbar = plt.colorbar(c, orientation='horizontal', shrink=0.8)
206 tick_locator = ticker.MaxNLocator(nbins=5) 206 tick_locator = ticker.MaxNLocator(nbins=5)
207 cbar.locator = tick_locator 207 cbar.locator = tick_locator
208 - cbar.update_ticks()  
209 cbar.set_label('arcmin') 208 cbar.set_label('arcmin')
210 209
211 # Show boundary contours 210 # Show boundary contours
@@ -339,7 +338,6 @@ def plot_edisp(sub, edisp, emin=None, emax=None, tmin=None, tmax=None, @@ -339,7 +338,6 @@ def plot_edisp(sub, edisp, emin=None, emax=None, tmin=None, tmax=None,
339 cbar1 = plt.colorbar(c1, orientation='horizontal', shrink=0.8) 338 cbar1 = plt.colorbar(c1, orientation='horizontal', shrink=0.8)
340 tick_locator = ticker.MaxNLocator(nbins=5) 339 tick_locator = ticker.MaxNLocator(nbins=5)
341 cbar1.locator = tick_locator 340 cbar1.locator = tick_locator
342 - cbar1.update_ticks()  
343 cbar1.set_label('E$_{reco}$ / E$_{true}$') 341 cbar1.set_label('E$_{reco}$ / E$_{true}$')
344 342
345 # Show boundary contours 343 # Show boundary contours
@@ -359,7 +357,6 @@ def plot_edisp(sub, edisp, emin=None, emax=None, tmin=None, tmax=None, @@ -359,7 +357,6 @@ def plot_edisp(sub, edisp, emin=None, emax=None, tmin=None, tmax=None,
359 cbar2 = plt.colorbar(c2, orientation='horizontal', shrink=0.8) 357 cbar2 = plt.colorbar(c2, orientation='horizontal', shrink=0.8)
360 tick_locator = ticker.MaxNLocator(nbins=5) 358 tick_locator = ticker.MaxNLocator(nbins=5)
361 cbar2.locator = tick_locator 359 cbar2.locator = tick_locator
362 - cbar2.update_ticks()  
363 cbar2.set_label('E$_{reco}$ / E$_{true}$') 360 cbar2.set_label('E$_{reco}$ / E$_{true}$')
364 361
365 # Show boundary contours 362 # Show boundary contours
@@ -427,6 +424,8 @@ def plot_bkg(sub, bkg, emin=None, emax=None, tmin=None, tmax=None, @@ -427,6 +424,8 @@ def plot_bkg(sub, bkg, emin=None, emax=None, tmin=None, tmax=None,
427 thetas = [tmax-i*dtheta for i in range(nthetas)] 424 thetas = [tmax-i*dtheta for i in range(nthetas)]
428 425
429 # Initialise image 426 # Initialise image
  427 + vmin = None
  428 + vmax = None
430 image = [] 429 image = []
431 430
432 # Loop over offset angles 431 # Loop over offset angles
@@ -448,11 +447,23 @@ def plot_bkg(sub, bkg, emin=None, emax=None, tmin=None, tmax=None, @@ -448,11 +447,23 @@ def plot_bkg(sub, bkg, emin=None, emax=None, tmin=None, tmax=None,
448 # Append value 447 # Append value
449 row.append(value) 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 # Append row 461 # Append row
452 image.append(row) 462 image.append(row)
453 463
454 # Plot image 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 cbar = plt.colorbar(c, orientation='horizontal', shrink=0.8) 467 cbar = plt.colorbar(c, orientation='horizontal', shrink=0.8)
457 cbar.set_label('s$^{-1}$ MeV$^{-1}$ sr$^{-1}$') 468 cbar.set_label('s$^{-1}$ MeV$^{-1}$ sr$^{-1}$')
458 469