fix axis in plot
@@ -7,7 +7,9 @@ from gammapy.modeling.models import PowerLawSpectralModel, SkyModel
from astropy.coordinates import SkyCoord
from regions import CircleSkyRegion
-region = CircleSkyRegion(center=SkyCoord(0, 0, unit="deg", frame="galactic"), radius=0.3 * u.deg)
+region = CircleSkyRegion(
+ center=SkyCoord(0, 0, unit="deg", frame="galactic"), radius=0.3 * u.deg
+)
m_dataset1 = MapDataset.read("$GAMMAPY_DATA/cta-1dc-gc/cta-1dc-gc.fits.gz")
dataset1 = m_dataset1.to_spectrum_dataset(region)
dataset1.mask_safe.data[0:2] = False
@@ -29,12 +31,12 @@ dataset_stacked.models = model
plt.figure(figsize=(20, 5))
-ax1 = plt.subplot(131, projection=dataset_stacked._geom.wcs)
-ax2 = plt.subplot(132, projection=dataset_stacked._geom.wcs)
-ax3 = plt.subplot(133, projection=dataset_stacked._geom.wcs)
+ax1 = plt.subplot(131)
+ax2 = plt.subplot(132)
+ax3 = plt.subplot(133)
-c1 = (dataset1.counts * dataset1.mask_safe)
-c2 = (dataset2.counts * dataset2.mask_safe)
+c1 = dataset1.counts * dataset1.mask_safe
+c2 = dataset2.counts * dataset2.mask_safe
c1.plot_hist(ax=ax1, label="dataset1")
c2.plot_hist(ax=ax1, label="dataset2")
@@ -43,15 +45,12 @@ dataset_stacked.counts.plot(ax=ax1, fmt="+", label="stacked", color="black")
ax1.legend()
ax1.set_title("counts")
-b1 = (dataset1.background * dataset1.mask_safe)
-b2 = (dataset2.background * dataset2.mask_safe)
+b1 = dataset1.background * dataset1.mask_safe
+b2 = dataset2.background * dataset2.mask_safe
b1.plot_hist(ax=ax2, label="dataset1")
b2.plot_hist(ax=ax2, label="dataset2")
-(b1 + b2
-).plot(color="green", ax=ax2, fmt="o", label="dataset1 + dataset2")
-dataset_stacked.background.plot(
- ax=ax2, fmt="+", label="stacked", color="black"
-)
+(b1 + b2).plot(color="green", ax=ax2, fmt="o", label="dataset1 + dataset2")
+dataset_stacked.background.plot(ax=ax2, fmt="+", label="stacked", color="black")
ax2.legend()
ax2.set_title("background")
@@ -63,5 +62,3 @@ n2 = dataset2.npred() * dataset2.mask_safe
dataset_stacked.npred().plot(fmt="+", label="stacked", color="black", ax=ax3)
ax3.legend()
ax3.set_title("npred")
-
-
