def main(argv): if len(argv) >= 2 and argv[0].upper() in ['A', 'B', 'AB']: protFiles = argv[1:] vial = argv[0] else: sys.exit( "\nusage: python generate_prest_report_multi.py <vial> <results_file1> (<results_file2> ...)\n where vial is one of 'A', 'B' or 'AB'." ) color_cycle = color.colors_from_cmap(len(protFiles), 'tab10') plt.rc('axes', prop_cycle=cycler('color', color_cycle.tolist())) #plt.rcParams['axes.color_cycle'] = p = plt.figure(figsize=(16, 12)) i = 0 for protFile in protFiles: plotPrestReport(protFile, vial.upper(), p) i += 1 handles, labels = p.get_axes()[-1].get_legend_handles_labels() p.legend(handles, labels, bbox_to_anchor=(0.5, 0., 0.45, 0.45), shadow=True, fontsize='x-large', loc='upper left') #plt.show() plt.savefig("result.svg")
def colfaxfig(simIa=None, simIbc=None, simII=None, contours=True, redshiftcircle=True, clobber=False, **plotargs): from pytools import plotsetup from matplotlib import pyplot as pl from mpltools import color from matplotlib import cm fig = plotsetup.fullpaperfig([8, 4]) simIa, simIbc, simII = doublecircle('colfax', simIa, simIbc, simII, clobber=clobber, circle1bands=['f139m', 'f127m'], circle2bands=['f139m', 'f153m'], contours=contours, redshiftcircle=redshiftcircle, **plotargs) fig = pl.gcf() ax1, ax2 = fig.axes fig.subplots_adjust(left=0.1, bottom=0.18, right=0.89, top=0.95, wspace=0.1) ax1.set_xlim(-0.5, 0.4) ax1.set_ylim(-0.7, 0.4) ax2.set_xlim(-0.5, 0.4) ax2.set_ylim(-0.4, 0.4) ax2.text( 0.95, 0.95, 'GND12Col', transform=ax2.transAxes, ha='right', va='top', color='k', fontsize=15, ) ax2.yaxis.labelpad = 20 colorlist = color.colors_from_cmap(2, cm.jet) ax1.text(0.15, 0.17, 'z=1.9', ha='left', va='top', color=colorlist[0]) ax1.text(-0.23, 0.32, 'z=2.4', ha='left', va='top', color=colorlist[1]) pl.draw() return simIa, simIbc, simII
def plot_all_annuli(self, projection="astro degrees mollweide", radius=None, center=None, cmap="Set1", **kwargs): assert projection in [ "astro degrees aitoff", "astro degrees mollweide", "astro hours aitoff", "astro hours mollweide", "astro globe", "astro zoom", ] skw_dict = dict(projection=projection) if projection in ["astro globe", "astro zoom"]: assert center is not None, "you must specify a center" skw_dict = dict(projection=projection, center=center) if projection == "astro zoom": assert radius is not None, "you must specify a radius" skw_dict = dict(projection=projection, center=center, radius=radius) fig, ax = plt.subplots(subplot_kw=skw_dict) # get the colors to use n_verts = self._n_detectors * (self._n_detectors - 1) / 2 colors = mpl_color.colors_from_cmap(n_verts, cmap=cmap) for i, (d1, d2) in enumerate(combinations(self._detectors.keys(), 2)): _ = self.plot_annulus(d1, d2, projection=projection, center=center, radius=radius, ax=ax, edgecolor=colors[i], **kwargs) return fig
def plotData(self): self.DataPlot.clear() # self.plotItem = self.DataPlot.getPlotItem() pa = self.plotAxes an0 = self.ax_name(pa[0]) an1 = self.ax_name(pa[1]) an2 = self.ax_name(pa[2]) if self.display_items[self.display_num] == 'Waterfall': grouped = self.item.groupby(an0) colors = np.array(255*color.colors_from_cmap(len(grouped), cmap='gnuplot', start=0.2, stop=0.8)) colors = colors.astype(int) i = -1 for label, data in grouped: i += 1 pen = pg.mkPen(pg.mkColor(colors[i])) x = np.array(data[an1]) y = np.array(data[an2]) self.plotItem.plot(x, y, pen= pen) elif self.display_items[self.display_num] == '2d plot': data = self.item.data x= data[an0] y= data[an1] z= np.array(data[an2]) # # define grid. nx = len(x.unique()) ny = len(y.unique()) # print(nx,ny) # nx = 512 # ny = 500 xi = np.linspace(min(x),max(x),nx) yi = np.linspace(min(y),max(y),ny) # grid the data. grid_z0 = griddata((x, y), z, (xi[None,:], yi[:,None]),method='nearest') img = pg.ImageItem(grid_z0.T) self.colorBar.setImageItem(img) self.plotItem.addItem(img) else: data = self.item.data x = data[an0] y = data[an1] self.plotItem.plot(x, y)
def plotData(self): self.DataPlot.clear() # self.plotItem = self.DataPlot.getPlotItem() pa = self.plotAxes if self.display_items[self.display_num] == 'Waterfall': g_axis = self.ax_name(pa[0]) grouped = self.item.groupby(g_axis) colors = np.array(255*color.colors_from_cmap(len(grouped), cmap='gnuplot', start=0.2, stop=0.8)) colors = colors.astype(int) xax = self.ax_name(pa[1]) yax = self.ax_name(pa[2]) i = -1 for label, data in grouped: i += 1 pen = pg.mkPen(pg.mkColor(colors[i])) x = np.array(data[xax]) y = np.array(data[yax]) self.plotItem.plot(x, y, pen= pen) elif self.display_items[self.display_num] == '2d plot': data = self.item.data values = data.ix[:, pa[2]] x = data.ix[:, pa[0]] y = data.ix[:, pa[1]] nx = min(500,len(x.unique()))*1j ny = min(500,len(y.unique()))*1j print(nx,ny) grid_x, grid_y = np.mgrid[0:1:nx, 0:1:ny] grid_z0 = griddata((x,y), np.array(values), (grid_x, grid_y), method='nearest') img = pg.ImageItem(grid_z0) self.colorBar.setImageItem(img) self.plotItem.addItem(img) else: data = self.item.data x = data.ix[:, pa[0]] y = data.ix[:, pa[1]] self.plotItem.plot(x, y)
def stonefig(simIa=None, simIbc=None, simII=None, contours=True, redshiftcircle=True, clobber=False, **plotargs): from pytools import plotsetup from mpltools import color from matplotlib import cm fig = plotsetup.fullpaperfig(figsize=[7.5, 3.5]) fig.clf() ax1 = fig.add_subplot(1, 2, 1) simIa, simIbc, simII = singlecircle( 'stone', simIa, simIbc, simII, clobber=clobber, medbandx='f139m', medbandy='f153m', contours=contours, redshiftcircle=False, #redshiftcircle, **plotargs) fig.subplots_adjust(left=0.10, bottom=0.15, right=0.92, top=0.98, wspace=0.0) ax1 = pl.gca() ax1.text( 0.05, 0.95, 'GND13Sto', transform=ax1.transAxes, ha='left', va='top', color='k', fontsize=15, ) ax2 = fig.add_subplot(1, 2, 2, sharex=ax1, sharey=ax1) singlecircle('stone', medbandx='f139m', medbandy='f153m', contours=False, points=False, redshiftcircle=True, **plotargs) #plot_redshift_circle(z_range=STONE.z_range, tobs=STONE.tobs, # medbandx='f139m', medbandy='f153m', # source='salt2', coloredaxislabels=False, marker='o' ) ax2.yaxis.set_label_position('right') ax2.yaxis.set_ticks_position('right') ax2.yaxis.set_ticks_position('both') pl.setp(ax2.yaxis.get_label(), rotation=-90) colorlist = color.colors_from_cmap(9, cm.jet) ax2.text(0.1, -0.15, 'z=1.6', ha='left', va='top', color=colorlist[0]) ax2.text(-0.06, -0.18, '1.7', ha='left', va='top', color=colorlist[1]) ax2.text(0.26, 0.06, '1.8', ha='left', va='top', color=colorlist[2]) ax2.text(0.14, 0.0, '1.9', ha='left', va='top', color='darkcyan') ax2.text(-0.1, -0.19, '2.0', ha='right', va='top', color='limegreen') ax2.text(-0.09, 0.23, '2.1', ha='right', va='bottom', color='darkolivegreen') ax2.text(0.13, 0.27, '2.2', ha='left', va='top', color=colorlist[6]) ax2.text(-0.1, -0.07, '2.3', ha='center', va='center', color=colorlist[7]) ax2.text(-0.23, -0.14, 'z=2.4', ha='right', va='bottom', color=colorlist[8]) ax1.set_xlim(-0.35, 0.35) ax1.set_ylim(-0.3, 0.45) pl.draw() return simIa, simIbc, simII
def plot_all_annuli( self, projection="astro degrees mollweide", radius=None, center=None, cmap="Set1", threeD=True, use_all=False, **kwargs, ): if not threeD: assert projection in [ "astro degrees aitoff", "astro degrees mollweide", "astro hours aitoff", "astro hours mollweide", "astro globe", "astro zoom", ] skw_dict = dict(projection=projection) if projection in ["astro globe", "astro zoom"]: assert center is not None, "you must specify a center" skw_dict = dict(projection=projection, center=center) if projection == "astro zoom": assert radius is not None, "you must specify a radius" skw_dict = dict(projection=projection, center=center, radius=radius) fig, ax = plt.subplots(subplot_kw=skw_dict) else: fig = ipv.figure() ipv.pylab.style.box_off() ipv.pylab.style.axes_off() ax = None # get the colors to use if use_all: n_verts = self._n_detectors * (self._n_detectors - 1) / 2 colors = mpl_color.colors_from_cmap(int(n_verts), cmap=cmap) for i, (d1, d2) in enumerate(combinations(self._detectors.keys(), 2)): _ = self.plot_annulus( d1, d2, projection=projection, center=center, radius=radius, ax=ax, edgecolor=colors[i], threeD=threeD, color=colors[i], **kwargs, ) if threeD: loc1 = self._detectors[d1].location.get_cartesian_coord( ).xyz.value loc2 = self._detectors[d2].location.get_cartesian_coord( ).xyz.value ipv.plot( np.array([loc1[0], loc2[0]]), np.array([loc1[1], loc2[1]]), np.array([loc1[2], loc2[2]]), color=colors[i], ) else: colors = mpl_color.colors_from_cmap(len(self._detectors) - 1, cmap=cmap) det_list = list(self._detectors.keys()) d1 = det_list[0] for i, d2 in enumerate(det_list[1:]): _ = self.plot_annulus( d1, d2, projection=projection, center=center, radius=radius, ax=ax, edgecolor=colors[i], threeD=threeD, color=colors[i], **kwargs, ) if threeD: loc1 = self._detectors[d1].location.get_cartesian_coord( ).xyz.value loc2 = self._detectors[d2].location.get_cartesian_coord( ).xyz.value ipv.plot( np.array([loc1[0], loc2[0]]), np.array([loc1[1], loc2[1]]), np.array([loc1[2], loc2[2]]), color=colors[i], ) if threeD: ipv.scatter( *(self._grb_radius * self._grb.location.get_cartesian_coord("gcrs").xyz.value / np.linalg.norm( self._grb.location.get_cartesian_coord("gcrs").xyz.value) )[np.newaxis].T, marker="sphere", color="green", ) ipv.show() return fig