You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to overlay contours on an image but I would like to use clabel and put some inline scales on the image but I wasn't successful and I couldn't find anything useful in the documentation of Aplpy
What I have written so far is like this :
def get_contour_verts(cn):
contours = []
# for each contour line
for cc in cn.collections:
paths = []
# for each separate section of the contour line
for pp in cc.get_paths():
xy = []
# for each segment of that section
for vv in pp.iter_segments():
xy.append(vv[0])
paths.append(np.vstack(xy))
contours.append(paths)
return contours
CS = plt.contour(Xgrid, Ygrid, Hsmooth, levels=levs,extent=extent,norm=LogNorm())
Contour_arrays=get_contour_verts(CS)
for contours_at_level,c in zip(Contour_arrays,colors):
clines = [cl.T for cl in contours_at_level]
img.show_lines(clines[3:],color='white',layer='contour_set_1',linestyle='solid', linewidth=0.15, zorder=100)
img._layers['contour_set_1'].clabel(clines[3:], inline=1, fontsize=20., fmt=ticker.LogFormatterMathtext())
img.save('image_rgb_arcsinh_contour.pdf')
The error:
File "Plot.Contour.Red.Galaxies.py", line 237, in
img._layers['contour_set_1'].clabel(clines[3:], inline=1, fontsize=20., fmt=ticker.Log
FormatterMathtext())
AttributeError: 'LineCollection' object has no attribute 'clabel'
Is it possible to write the contour level over each line?
The text was updated successfully, but these errors were encountered:
I am trying to overlay contours on an image but I would like to use clabel and put some inline scales on the image but I wasn't successful and I couldn't find anything useful in the documentation of Aplpy
What I have written so far is like this :
def get_contour_verts(cn):
contours = []
# for each contour line
for cc in cn.collections:
paths = []
# for each separate section of the contour line
for pp in cc.get_paths():
xy = []
# for each segment of that section
for vv in pp.iter_segments():
xy.append(vv[0])
paths.append(np.vstack(xy))
contours.append(paths)
return contours
lev_exp = np.arange(np.floor(np.log10(zp.min())-1), np.ceil(np.log10(zp.max())+1))
levs = np.power(10, lev_exp)
bins_x=np.linspace(min(xp),max(xp),nx)
bins_y=np.linspace(min(yp),max(yp),ny)
H, yedges, xedges = np.histogram2d(xp, yp, (bins_x,bins_y),weights=zp)
smooth=0.7
Hsmooth = scipy.ndimage.filters.gaussian_filter(H.T, smooth)
xcenters = (xedges[1:] + xedges[:-1])/2.
ycenters = (yedges[1:] + yedges[:-1])/2.
Xgrid, Ygrid = np.meshgrid(ycenters, xcenters)
extent = [xedges[0], xedges[-1], yedges[0], yedges[-1] ]
print len(ra),len(Gcl_1_ra),len(Gcl_2_ra)
Now we add contours
CS = plt.contour(Xgrid, Ygrid, Hsmooth, levels=levs,extent=extent,norm=LogNorm())
Contour_arrays=get_contour_verts(CS)
for contours_at_level,c in zip(Contour_arrays,colors):
clines = [cl.T for cl in contours_at_level]
img.show_lines(clines[3:],color='white',layer='contour_set_1',linestyle='solid', linewidth=0.15, zorder=100)
img._layers['contour_set_1'].clabel(clines[3:], inline=1, fontsize=20., fmt=ticker.LogFormatterMathtext())
img.save('image_rgb_arcsinh_contour.pdf')
The error:
File "Plot.Contour.Red.Galaxies.py", line 237, in
img._layers['contour_set_1'].clabel(clines[3:], inline=1, fontsize=20., fmt=ticker.Log
FormatterMathtext())
AttributeError: 'LineCollection' object has no attribute 'clabel'
Is it possible to write the contour level over each line?
The text was updated successfully, but these errors were encountered: