本文整理汇总了Python中matplotlib.backends.backend_agg.FigureCanvasAgg.print_jpg方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasAgg.print_jpg方法的具体用法?Python FigureCanvasAgg.print_jpg怎么用?Python FigureCanvasAgg.print_jpg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_agg.FigureCanvasAgg
的用法示例。
在下文中一共展示了FigureCanvasAgg.print_jpg方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ant_ant_stat_frame
# 需要导入模块: from matplotlib.backends.backend_agg import FigureCanvasAgg [as 别名]
# 或者: from matplotlib.backends.backend_agg.FigureCanvasAgg import print_jpg [as 别名]
def ant_ant_stat_frame(title_text, full_pol_array, station_names, output_name=None, dpi=50, **kwargs):
if output_name is None:
fig = figure(figsize=(32,30), dpi=dpi)
else:
fig=Figure(figsize=(32,30), dpi=dpi)
if output_name is None:
fig.suptitle(title_text, fontsize=30)
else:
fig.suptitle(title_text+' '+output_name, fontsize=30)
ax1=fig.add_subplot(2,2,1)
ant_ant_stat_plot(fig, ax1, title_text+' XX', full_pol_array[:,:,0], station_names, **kwargs)
ax2=fig.add_subplot(2,2,2)
ant_ant_stat_plot(fig, ax2, title_text+' XY', full_pol_array[:,:,1], station_names, **kwargs)
ax3=fig.add_subplot(2,2,3)
ant_ant_stat_plot(fig, ax3, title_text+' YX', full_pol_array[:,:,2], station_names, **kwargs)
ax4=fig.add_subplot(2,2,4)
ant_ant_stat_plot(fig, ax4, title_text+' YY', full_pol_array[:,:,3], station_names, **kwargs)
if output_name is not None:
canvas = FigureCanvasAgg(fig)
if output_name[-4:] in ['.jpg', '.JPG']:
canvas.print_jpg(output_name, dpi=dpi, quality=55)
else:
canvas.print_figure(output_name, dpi=dpi)
pass
pass
示例2: saveWithAxes
# 需要导入模块: from matplotlib.backends.backend_agg import FigureCanvasAgg [as 别名]
# 或者: from matplotlib.backends.backend_agg.FigureCanvasAgg import print_jpg [as 别名]
def saveWithAxes(img):
fig = Figure()
axes = fig.add_subplot(111)
axes.imshow(img, cmap=cm.Greys_r)
canvas = FigureCanvas(fig)
# TODO: Need to find a way to avoid this hack!
canvas.print_jpg("run.img.tmp.jpg")
return numpy.array(Image.open("run.img.tmp.jpg"))
示例3: histogram
# 需要导入模块: from matplotlib.backends.backend_agg import FigureCanvasAgg [as 别名]
# 或者: from matplotlib.backends.backend_agg.FigureCanvasAgg import print_jpg [as 别名]
def histogram(img):
fig = Figure()
axes = fig.add_subplot(111)
if len(img.shape) == 2 or img.shape[2:][0] == 1:
axes.hist(img.flatten(), 300, color='blue', edgecolor='none')
else:
img = cv2.cvtColor(img, cv2.cv.CV_RGB2HSV)
axes.hist([img[...,0], img[...,1], img[...,2]], 128, color=['red', 'green', 'blue'], edgecolor='none')
axes.legend(('Hue', 'Saturation', 'Value'))
#axes.legend(('Red', 'Green', 'Blue'))
# If hsv, should look something like this.
# axes.hist([img[...,0], img[...,1], img[...,2]], 300, color=['r','g','b'])
axes.grid(True)
setp(axes.get_yticklabels(), visible=False)
canvas = FigureCanvas(fig)
canvas.print_jpg("run.hist.tmp.jpg")
return Image.open("run.hist.tmp.jpg")
示例4: timeseries_station_page
# 需要导入模块: from matplotlib.backends.backend_agg import FigureCanvasAgg [as 别名]
# 或者: from matplotlib.backends.backend_agg.FigureCanvasAgg import print_jpg [as 别名]
def timeseries_station_page(ms, station_name, time_slots, data, fn=abs, output_name=None):
dpi=50
if output_name is None:
fig = figure(figsize=(32,24), dpi=dpi)
else:
fig = Figure(figsize=(32,24), dpi=dpi)
station_name_list = list(ms.tables['antennae']['NAME'])
station_id = station_name_list.index(station_name)
num_ant = len(ms.tables['antennae'])
tsn = time_slots-time_slots[0]
pol_names = corr_type(ms.tables['polarization']['CORR_TYPE'][0])
ref_freq_mhz = ms.tables['spectral_windows'][0]['REF_FREQUENCY']/1.e6
fig.suptitle(ms.msname+': '+fn.__name__+'(vis) with '+station_name+' at %3.2f MHz' % (ref_freq_mhz,), fontsize='large')
median_amp = ma.median(ma.mean(ma.median(fn(data[station_id,:,0::3,:]), axis=-1), axis=-1), axis=-1)
for id2,name in enumerate(station_name_list):
ax = fig.add_subplot(ceil(num_ant/4.0),4, id2+1)
ax.plot(tsn, fn(data[station_id,id2,0,:]), c='blue' , label=pol_names[0])
ax.plot(tsn, fn(data[station_id,id2,1,:]), c='green' , label=pol_names[1])
ax.plot(tsn, fn(data[station_id,id2,2,:]), c='purple', label=pol_names[2])
ax.plot(tsn, fn(data[station_id,id2,3,:]), c='red' , label=pol_names[3])
ax.grid()
ax.set_ylabel(station_name_list[id2], rotation='horizontal')
ax.set_ylim(0.0, 3*median_amp)
ax.set_yticklabels([])
if id2 < len(station_name_list)-4:
ax.set_xticklabels([])
else:
ax.set_xlabel('Time [s]')
pass
fig.subplots_adjust(hspace=0.0, top=0.95, bottom=0.04)
if output_name is not None:
canvas = FigureCanvasAgg(fig)
if output_name[-4:] in ['.jpg', '.JPG']:
canvas.print_jpg(output_name, dpi=dpi, quality=55)
else:
canvas.print_figure(output_name, dpi=dpi)
pass
pass
示例5: station_gain_bar_chart
# 需要导入模块: from matplotlib.backends.backend_agg import FigureCanvasAgg [as 别名]
# 或者: from matplotlib.backends.backend_agg.FigureCanvasAgg import print_jpg [as 别名]
def station_gain_bar_chart(ms, station_name, time_slots, data, output_name= None):
dpi=50
if output_name is None:
fig = figure(figsize=(38,24), dpi=dpi)
else:
fig = Figure(figsize=(38,24), dpi=dpi)
station_name_list = list(ms.tables['antennae']['NAME'])
num_stations = len(station_name_list)
station_id = station_name_list.index(station_name)
ref_freq_mhz = ms.tables['spectral_windows'][0]['REF_FREQUENCY']/1.e6
is_autocorrelation = array([station_name == name for name in ms.tables['antennae']['NAME']])
noise = ma.array(data[station_id,:, 1:3,:].imag.std(axis=-1).mean(axis=-1),
mask = is_autocorrelation)
sig = median(abs(data[station_id, :, :, :]),axis=-1)
signal = ma.array(sig, mask = is_autocorrelation[:, newaxis]*ones((num_stations, 4)))
ax = fig.add_subplot(1,1,1)
xx_bars = ax.bar(arange(len(station_name_list))-0.4, signal[:, 0], width=0.2, color='blue', label='xx')
xy_bars = ax.bar(arange(len(station_name_list))-0.2, signal[:, 1], width=0.2, color='lightblue', label='xy')
yx_bars = ax.bar(arange(len(station_name_list)) , signal[:, 2], width=0.2, color='lightpink', label='yx')
yy_bars = ax.bar(arange(len(station_name_list))+0.2, signal[:, 3], width=0.2, color='red', label='yy')
for x_pos, name in enumerate(station_name_list):
if name != station_name:
ax.text(x_pos, signal[x_pos,:].max()*1.02, name, rotation='vertical',
horizontalalignment='center', verticalalignment='bottom',
fontsize=25)
ax.text(x_pos, signal[x_pos,:].max()*-0.01, name, rotation='vertical',
horizontalalignment='center', verticalalignment='top',
fontsize=25)
else:
ax.text(x_pos, 0.0, ' Reference station: '+name, rotation='vertical',
horizontalalignment='center', verticalalignment='bottom',
fontsize=25)
ax.set_xlabel('Station', fontsize=40)
ax.set_ylabel('Visibility amplitude', fontsize=40)
ax.set_ylim(0, ma.max(signal)*1.2)
ax.set_xlim(-1.0, num_stations)
ax.set_xticklabels([])
ax.set_title('%s:\nVis. amp. with station %s at %5.2f MHz' %
(ms.msname, station_name, ref_freq_mhz),
fontsize=40)
old_legend_fontsize = rcParams['legend.fontsize']
rcParams.update({'legend.fontsize': 25})
legend_instance = ax.legend()
for label in ax.get_yticklabels():
label.set_fontsize(40)
if output_name is not None:
canvas = FigureCanvasAgg(fig)
if output_name[-4:] in ['.jpg', '.JPG']:
canvas.print_jpg(output_name, dpi=dpi, quality=55)
else:
canvas.print_figure(output_name, dpi=dpi)
pass
rcParams.update({'legend.fontsize': old_legend_fontsize})