python - Adding title to the column of subplot below suptitle -
is there simple way add in original code can add title both column of subplot? example somewhere in pink region shown in picture below.
someone refer me @ post solution looking see if there method without using loop
my code:
import cv2 import numpy np import matplotlib.pyplot plt path = 'r:\\temp\\ming\\' path1 = 'r:\\temp\\ming\\' def hue(im_file): im = cv2.imread(im_file) im = cv2.cvtcolor(im, cv2.color_bgr2hsv_full) # hue value= range[0,360] im1 = im[776, 402] hue = im1[0] return hue def saturation(im_file): im = cv2.imread(im_file) im = cv2.cvtcolor(im, cv2.color_bgr2hsv_full) #return saturation value = range[0,255] im1 = im[776, 402] saturation = im1[1] return saturation def value(im_file): im = cv2.imread(im_file) im = cv2.cvtcolor(im, cv2.color_bgr2hsv_full) #return value(brightness) value = range[0,255] im1 = im[776, 402] value = im1[2] return value def bluecomponent(im_file): im = cv2.imread(im_file) #return blue value im1 = im[776, 402] b = im1[0] return b def greencomponent(im_file): im = cv2.imread(im_file) #return green value im1 = im[776, 402] g = im1[1] return g def redcomponent(im_file): #return red value im = cv2.imread(im_file) im1 = im[776, 402] r = im1[2] return r myhuelist = [] mysaturationlist = [] myvaluelist = [] mybluelist = [] mygreenlist = [] myredlist = [] mylist = [] num_images = 99 # number of images dotpos = 0 in range(1770, 1869): # loop auto-generate image names , run prior function image_name = path + 'cropped_aligned_img_' + str(i) + '.png' # loop runs image number 1770 1868 myhuelist.append(hue(image_name)) mysaturationlist.append(saturation(image_name)) myvaluelist.append(value(image_name)) mybluelist.append(bluecomponent(image_name)) mygreenlist.append(greencomponent(image_name)) myredlist.append(redcomponent(image_name)) mylist.append(dotpos) dotpos = dotpos + 0.5 print(mybluelist) print(mygreenlist) print(myredlist) print(myhuelist) print(mysaturationlist) print(myvaluelist) print(mylist) k in range(1770,1869): = 'cropped_aligned_img_' + str(k) image_name = path + + '.png' img_file = cv2.imread(image_name) x = mylist y = mybluelist y1 = mygreenlist y2 = myredlist y3 = myhuelist y4 = mysaturationlist y5 = myvaluelist plt.axes([0.1, 0.1, 1, 1]) plt.suptitle('bgr & hsv color decimal code against function of time(hours)', fontsize=14, fontweight='bold') plt.subplot(3,2,1) plt.plot(x, y, 'b.-') plt.title('blue component color decimal code') plt.xlabel('time(hours)') plt.ylabel('colour code') plt.subplot(3,2,3) plt.plot(x, y1, 'g.-') plt.title('green component color decimal code') plt.xlabel('time(hours)') plt.ylabel('colour code') plt.subplot(3,2,5) plt.plot(x, y2, 'r.-') plt.title('red component color decimal code') plt.xlabel('time(hours)') plt.ylabel('colour code') plt.subplot(3,2,2) plt.plot(x, y3, 'b.-') plt.title('hue component hsv color decimal code') plt.xlabel('time(hours)') plt.ylabel('colour code') plt.subplot(3,2,4) plt.plot(x, y4, 'g.-') plt.title('saturation component hsv color decimal code') plt.xlabel('time(hours)') plt.ylabel('colour code') plt.subplot(3,2,6) plt.plot(x, y5, 'r.-') plt.title('value component hsv color decimal code') plt.xlabel('time(hours)') plt.ylabel('colour code') plt.subplots_adjust(hspace = 0.5) plt.show()
i imagine creating empty row of subplots @ top, each of subplots having own title act column title.
import matplotlib.pyplot plt import numpy np plt.rcparams["figure.figsize"] = 6,8 colors = plt.rcparams["axes.prop_cycle"].by_key()["color"] x = np.linspace(-3,3) y = np.random.randn(len(x),6) fig, axes = plt.subplots(ncols=2, nrows=3+1, gridspec_kw={"height_ratios":[0.02,1,1,1]}) fig.suptitle('some long super title complete figure', fontsize=14, fontweight='bold') i, ax in enumerate(axes.flatten()[2:]): ax.plot(x,y[:,i], color=colors[i%6]) ax.set_title("title {}".format(i+1)) i, ax in enumerate(axes.flatten()[:2]): ax.axis("off") ax.set_title("columntitle {}".format(i+1), fontweight='bold') fig.subplots_adjust(hspace=0.5, bottom=0.1) plt.show()
note i'm using loops here in order simplify things. of course can type in commands each subplots individually, if desireable reason.
Comments
Post a Comment