Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""Display the given set of images, optionally with titles.
images: list or array of image tensors in HWC format.
titles: optional. A list of titles to display with each image.
cols: number of images per row
cmap: Optional. Color map to use. For example, "Blues".
norm: Optional. A Normalize instance to map values to colors.
interpolation: Optional. Image interporlation to use for display.
"""
titles = titles if titles is not None else [""] * len(images)
rows = len(images) // cols + 1
plt.figure(figsize=(14, 14 * rows // cols))
i = 1
for image, title in zip(images, titles):
plt.subplot(rows, cols, i)
plt.title(title, fontsize=9)
plt.axis('off')
plt.imshow(image.astype(np.uint8), cmap=cmap,
norm=norm, interpolation=interpolation)
i += 1
plt.show()
plt.figure('adjust_gamma', figsize=(10, 4))
plt.subplot(221)
plt.title('origin dark image')
plt.imshow(img_dark)
plt.axis('off')
plt.subplot(222)
plt.title('gamma=0.3')
plt.imshow(gam1)
plt.axis('off')
plt.subplot(223)
plt.title('origin light image')
plt.imshow(img_light)
plt.axis('off')
plt.subplot(224)
plt.title('gamma=2')
plt.imshow(gam2)
plt.axis('off')
plt.show()
plt.plot(cities[:,0],cities[:,1],'bo-')
#plt.scatter(cities[:,0], cities[:,1],s=50,c='k')
if gain < 0:
plt.scatter(cities2[:,0], cities2[:,1],c='r',s=180)
plt.plot(cities2[:,0],cities2[:,1],c='r',linewidth=2)
plt.scatter(cities3[:,0], cities3[:,1],c='b',s=150)
plt.plot(cities3[:,0],cities3[:,1],c='r',linewidth=2)
else:
plt.scatter(cities2[:,0], cities2[:,1],c='g',s=180)
plt.plot(cities2[:,0],cities2[:,1],c='g',linewidth=2)
plt.scatter(cities3[:,0], cities3[:,1],c='b',s=150)
plt.plot(cities3[:,0],cities3[:,1],c='g',linewidth=2)
plt.axis( [-100,4100,-100,2100] )
plt.axis('off')
plt.title('(3) 2-Opt Tour {:6.1f}'.format(l_min))
plt.savefig( ("%05d" % pic)+'.png')
plt.clf()
pic += 1
print pic
fig_settings = {
'lines.linewidth': 0.5,
'axes.linewidth': 0.5,
'axes.labelsize': 'small',
'legend.fontsize': 'small',
}
mplt.rcParams.update(fig_settings)
mplt.figure(figsize=(13, 10))
mplt.subplot(311)
mplt.grid(True)
mplt.axis([0, t_sim_time, -.2, len(C2_populations) - .8])
for i in range(len(C2_populations)):
st = C2_populations[i].get_data().segments[0].spiketrains[0]
mplt.plot(st, np.ones_like(st) * i, '.')
mplt.subplot(312)
mplt.axis([0, t_sim_time, -.2, len(classifier_neurons) - .8])
for i in range(len(classifier_neurons)):
st = classifier_neurons[i].get_data().segments[0].spiketrains[0]
mplt.plot(st, np.ones_like(st) * i, '.')
mplt.subplot(313)
mplt.axis([0, t_sim_time, -66, -49])
for i in range(len(classifier_neurons)):
segm = classifier_neurons[i].get_data().segments[0]
voltages = segm.filter(name='v')[0]
mplt.plot(voltages.times, voltages, label=str(i))
mplt.savefig('plots/CLF/{}_{}.png'.format(results_label, appendix))
def main():
"Example data generation"
X, Y = get_curves(noise='normal', scale=0.2)
import matplotlib.pyplot as plt
plt.subplot2grid((3, 1), (0, 0))
plt.axis('off')
plt.plot(X, Y ,'k.')
plt.subplot2grid((3, 1), (1, 0), rowspan = 2)
plt.axis('off')
X, Y = get_square(noise='normal', scale=0.2)
plt.plot(X, Y ,'k.')
plt.show()
import matplotlib.pyplot as plt
fig = plt.figure()
plt.triplot(self.points[:,0],self.points[:,1], self.elements[:,:3])
plt.tricontourf(self.points[:,0], self.points[:,1], self.elements[:,:3], np.ones(self.points.shape[0]), 100,alpha=0.3)
for i in range(0,self.elements.shape[0]):
coord = self.points[self.elements[i,:],:]
x_avg = np.sum(coord[:,0])/self.elements.shape[1]
y_avg = np.sum(coord[:,1])/self.elements.shape[1]
plt.text(x_avg,y_avg,str(i),backgroundcolor='#F88379',ha='center')
for i in range(0,self.points.shape[0]):
plt.text(self.points[i,0],self.points[i,1],str(i),backgroundcolor='#0087BD',ha='center')
plt.axis('equal')
# plt.show(block=False)
plt.show()
colors = [legend_theme2(1. * i / len(data)) for i in range(len(method_list))]
ax2.set_prop_cycle("color", colors)
data = []
for k in method_list:
data.append(np.sum([element[k]["total_seconds"] for name, element in result_dict.items() if k in element]))
patches_an, _, _ = plt.pie([val/sum(data) for val in data],
shadow=True,
startangle=90,
pctdistance=0.7,
autopct=eval_mean_time_autopct(data))
append_plotly(labels=method_list, values=[val / sum(data) for val in data], name="methods",
colors=[(col) for col in colors],
domain={'x': [0, 1], 'y': [0, 0.45]})
plt.axis('equal')
plt.title("methods")
plt.legend(
loc='lower left',
labels=['%s' % l for l in method_list],
prop={'size': 10},
bbox_transform=fig.transFigure
)
# for only one legend
#fig.legend(patches+patches_an, element_names+method_list, prop={'size': 10}, loc='lower left')
if write_results:
plt.savefig(os.path.join(self.output_settings.results_folder, 'time_monitor_pie.png'))
plt.close()
if plotly_return:
str_fig = "var layout =" + str(plotly_dict["layout"]) + ";"
pyplot.title(title)
xlabel = options.get('xlabel', '')
pyplot.xlabel(xlabel)
ylabel = options.get('ylabel', '')
pyplot.ylabel(ylabel)
if 'xscale' in options:
pyplot.xscale(options['xscale'])
if 'yscale' in options:
pyplot.yscale(options['yscale'])
if 'axis' in options:
pyplot.axis(options['axis'])
loc = options.get('loc', 0)
legend = options.get('legend', True)
if legend:
pyplot.legend(loc=loc)
if formats is None:
formats = ['eps', 'png', 'pdf']
if root:
for format in formats:
saveFormat(root, format)
show = options.get('show', False)
if show:
pyplot.show()
def show_comparison(font_num, real_targets, fake_targets, show_num=8):
plt.figure(figsize=(14, show_num//2+1))
for idx in range(show_num):
plt.subplot(show_num//4, 8, 2*idx+1)
plt.imshow(real_targets[font_num][idx].reshape(128, 128), cmap='gray')
plt.title("Real [%d]" % font_num)
plt.axis('off')
plt.subplot(show_num//4, 8, 2*idx+2)
plt.imshow(fake_targets[font_num][idx].reshape(128, 128), cmap='gray')
plt.title("Fake [%d]" % font_num)
plt.axis('off')
plt.show()
def evaluate_threshold(images):
# rgb, false, enhanced, ndvi = images
# w = 2; h = 2
fig = plt.figure(figsize=(2, 2))
columns = 2
rows = 2
for i in range(columns * rows):
images[i] = np.asarray(images[i])
fig.add_subplot(rows, columns, i+1)
if images[i].ndim == 2:
plt.gray()
plt.axis('off')
plt.imshow(images[i])
# fig.set_size_inches(np.array(fig.get_size_inches()) * len(images))
plt.show()
pass