def visualize_array(image_data, label='data_figure'): """ Produce a visual representation of the image_data matrix. Parameters ---------- image_data : 2D array of floats The pixel values to make into an image. label : str The string label to affix to the image. It is used both to generate a figure number and as the title. """ # Treat nan values like zeros for display purposes image_data = np.nan_to_num(np.copy(image_data)) fig = plt.figure(str_to_int(label)) # Diane made the brilliant suggestion to leave this plot in color. # It looks much prettier. plt.summer() im = plt.imshow(image_data) im.set_interpolation('nearest') plt.title(label) plt.xlabel('Max = {0:.3}, Min = {1:.3}'.format(np.max(image_data), np.min(image_data))) fig.show() fig.canvas.draw()
def visualize_array(image_data, label="data_figure"): """ Produce a visual representation of the image_data matrix. Parameters ---------- image_data : 2D array of floats The pixel values to make into an image. label : str The string label to affix to the image. It is used both to generate a figure number and as the title. """ # Treat nan values like zeros for display purposes image_data = np.nan_to_num(np.copy(image_data)) fig = plt.figure(str_to_int(label)) # Diane made the brilliant suggestion to leave this plot in color. # It looks much prettier. plt.summer() im = plt.imshow(image_data) im.set_interpolation("nearest") plt.title(label) plt.xlabel("Max = {0:.3}, Min = {1:.3}".format(np.max(image_data), np.min(image_data))) fig.show() fig.canvas.draw()
def visualize_array(image_data, shape=None, save_eps=False, label='data_figure', epsfilename=None, show=True): """ Produce a visual representation of the image_data matrix """ if shape is None: shape = image_data.shape if epsfilename is None: epsfilename = 'log/' + label + '.eps' fig = plt.figure(str_to_int(label)) # Treat nan values like zeros for display purposes image_data = np.nan_to_num(np.copy(image_data)) # Diane made the brilliant suggestion to leave this plot in color. # It looks much prettier. plt.summer() im = plt.imshow(image_data[0:shape[0], 0:shape[1]]) im.set_interpolation('nearest') plt.title(label) if show: fig.show() fig.canvas.draw() if save_eps: fig.savefig(epsfilename, format='eps') return
def stream_plot(): """範囲指定""" plt.xlim(-2.0, 2.0) plt.ylim(-2.0, 2.0) """流線を描く""" plt.contour(xi[:, :], eta[:, :], g[:, :], locator=plt.MultipleLocator(0.05)) plt.summer() """翼を描く(翼はξ、ηの配列のr=0の部分)""" plt.plot(xi[:, 0], eta[:, 0]) plt.title('Sream Line') plt.xlabel("ξ") plt.ylabel("η") cbar = plt.colorbar() cbar.set_label("ψ") plt.show()
def visualize_array(image_data, shape=None, save_eps=False, label='data_figure', epsfilename=None): """ Produce a visual representation of the image_data matrix """ if shape is None: shape = image_data.shape if epsfilename is None: epsfilename = 'log/' + label + '.eps' fig = plt.figure(str_to_int(label)) # Diane made the brilliant suggestion to leave this plot in color. # It looks much prettier. plt.summer() im = plt.imshow(image_data[0:shape[0], 0:shape[1]]) im.set_interpolation('nearest') plt.title(label) fig.show() fig.canvas.draw() if save_eps: fig.savefig(epsfilename, format='eps') return
intensity = make_ward_dictionary(df, "Primary Type", "NARCOTICS", "Case Number") row = 10 column = 5 count = 1 w_array = [[0] * column for _ in range(row)] for i in range(row): for j in range(column): w_array[i][j] = intensity[count] count += 1 intens_list1 = list(intensity.values()) max_intens1 = max(intens_list1) plt.pcolor(w_array) plt.colorbar() plt.summer() plt.title("Chicago Narcotics by Ward") plt.xlabel("Ward Number Mod 5 on right") plt.show() with open("311_Service_Requests_-_Vacant_and_Abandoned_Buildings_Reported.csv" ) as vacant: '''Second Heatmap for Vacant and Abandoned Buildings in Chicago By Ward''' data = pd.read_csv(vacant, low_memory=False) intensity = make_ward_dictionary(data, "SERVICE REQUEST TYPE", "Vacant/Abandoned Building", "SERVICE REQUEST NUMBER") row = 10 column = 5 count = 1
bad temp_new_M = np.delete(M, bad, axis =0) new_M = np.delete(temp_new_M, bad, axis =1) num_cohorts midpoint_list = [] i = 0 for pop in pop_list: midpoint_list.append(num_cohorts * (i + .5) ) i += 1 import matplotlib.pyplot as plt plt.matshow(new_M) plt.summer() #x = midpoint_dict.values() #names = midpoint_dict.keys() plt.xticks(midpoint_list, pop_list) plt.yticks(midpoint_list, pop_list) title = ' L2 distance between deciles of length dist, '+str(2*num_samples)+' haps = '+str(num_samples)+' ind' plt.title(title) #plt.subplot(121) plt.show()