python - Error in plotting line graph -


appreciate if explain me went wrong?

1) couldnt plot line graph....i managed plot data point marker('r.') or round marker('r.'), plot blank no data when tried plot line graph changing ('r-')

below code produce figure , data printed out

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)     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)     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)     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(myhuelist) print(mysaturationlist) print(myvaluelist) print(mylist) print(mybluelist) print(mygreenlist) print(myredlist)   k in range(1770,1869):     = 'cropped_aligned_img_' + str(k)     image_name = path + + '.png'     img_file = cv2.imread(image_name)  y = [mybluelist] x = [mylist] 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 have copy out data below:

myhuelist = [5, 4, 5, 5, 5, 5, 6, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 5, 5, 6, 5, 6, 5, 5, 5, 5, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 4, 6, 6, 5, 6, 6, 6, 6, 5, 4, 4, 5, 6, 6, 5, 6, 6, 6, 4, 4, 4, 5, 6, 5, 4, 5, 5, 5, 5, 4, 4, 5, 5, 4, 3, 5, 3, 3, 3, 2, 1, 3, 3, 4, 1, 1, 1, 0, 2, 0, 1, 1, 2, 2, 2]  mysaturationlist = [99, 95, 102, 99, 98, 102, 99, 99, 96, 99, 102, 100, 99, 95, 94, 102, 105, 98, 97, 107, 105, 104, 107, 102, 109, 102, 101, 102, 96, 102, 105, 97, 100, 97, 99, 100, 99, 100, 99, 100, 106, 100, 102, 99, 96, 104, 102, 102, 104, 104, 100, 99, 95, 101, 105, 96, 101, 101, 107, 100, 105, 102, 100, 97, 103, 104, 106, 99, 96, 97, 97, 97, 104, 93, 96, 98, 101, 93, 88, 93, 83, 84, 82, 79, 78, 83, 78, 79, 80, 74, 72, 75, 75, 71, 71, 66, 74, 76, 73]  myvaluelist = [137, 134, 133, 137, 138, 133, 139, 136, 135, 131, 123, 135, 137, 132, 135, 125, 121, 133, 134, 121, 134, 135, 119, 137, 133, 123, 134, 125, 135, 138, 121, 134, 135, 139, 137, 138, 142, 135, 137, 135, 135, 135, 133, 131, 133, 123, 132, 137, 123, 135, 135, 141, 142, 137, 122, 136, 137, 137, 121, 138, 134, 138, 127, 140, 124, 137, 125, 137, 130, 139, 140, 139, 123, 137, 135, 128, 134, 137, 136, 134, 142, 139, 143, 139, 137, 144, 138, 149, 127, 141, 142, 136, 143, 136, 141, 135, 144, 141, 144]  mylist = [0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0, 8.5, 9.0, 9.5, 10.0, 10.5, 11.0, 11.5, 12.0, 12.5, 13.0, 13.5, 14.0, 14.5, 15.0, 15.5, 16.0, 16.5, 17.0, 17.5, 18.0, 18.5, 19.0, 19.5, 20.0, 20.5, 21.0, 21.5, 22.0, 22.5, 23.0, 23.5, 24.0, 24.5, 25.0, 25.5, 26.0, 26.5, 27.0, 27.5, 28.0, 28.5, 29.0, 29.5, 30.0, 30.5, 31.0, 31.5, 32.0, 32.5, 33.0, 33.5, 34.0, 34.5, 35.0, 35.5, 36.0, 36.5, 37.0, 37.5, 38.0, 38.5, 39.0, 39.5, 40.0, 40.5, 41.0, 41.5, 42.0, 42.5, 43.0, 43.5, 44.0, 44.5, 45.0, 45.5, 46.0, 46.5, 47.0, 47.5, 48.0, 48.5, 49.0]  mybluelist = [84, 84, 80, 84, 85, 80, 85, 83, 84, 80, 74, 82, 84, 83, 85, 75, 71, 82, 83, 70, 79, 80, 69, 82, 76, 74, 81, 75, 84, 83, 71, 83, 82, 86, 84, 84, 87, 82, 84, 82, 79, 82, 80, 80, 83, 73, 79, 82, 73, 80, 82, 86, 89, 83, 72, 85, 83, 83, 70, 84, 79, 83, 77, 87, 74, 81, 73, 84, 81, 86, 87, 86, 73, 87, 84, 79, 81, 87, 89, 85, 96, 93, 97, 96, 95, 97, 96, 103, 87, 100, 102, 96, 101, 98, 102, 100, 102, 99, 103]  mygreenlist = [90, 89, 86, 90, 91, 86, 92, 89, 90, 86, 80, 88, 90, 89, 90, 80, 76, 88, 89, 76, 87, 88, 76, 90, 86, 80, 87, 82, 90, 91, 77, 89, 88, 92, 89, 89, 93, 88, 90, 88, 86, 88, 86, 86, 88, 80, 86, 88, 80, 88, 89, 94, 95, 88, 77, 91, 90, 90, 76, 91, 87, 91, 82, 92, 79, 88, 80, 90, 86, 92, 93, 92, 79, 92, 89, 85, 87, 92, 92, 91, 99, 96, 100, 98, 96, 100, 99, 107, 88, 101, 103, 96, 103, 98, 103, 101, 104, 101, 105]  myredlist = [137, 134, 133, 137, 138, 133, 139, 136, 135, 131, 123, 135, 137, 132, 135, 125, 121, 133, 134, 121, 134, 135, 119, 137, 133, 123, 134, 125, 135, 138, 121, 134, 135, 139, 137, 138, 142, 135, 137, 135, 135, 135, 133, 131, 133, 123, 132, 137, 123, 135, 135, 141, 142, 137, 122, 136, 137, 137, 121, 138, 134, 138, 127, 140, 124, 137, 125, 137, 130, 139, 140, 139, 123, 137, 135, 128, 134, 137, 136, 134, 142, 139, 143, 139, 137, 144, 138, 149, 127, 141, 142, 136, 143, 136, 141, 135, 144, 141, 144] 

the data stored in list of list. i.e. have [[1,2,3]] instead of [1,2,3]. not understood correctly matplotlib, such no lines drawn in between points.

to correctly produce required lists, use

y = mybluelist x = mylist y1 = mygreenlist y2 = myredlist y3 = myhuelist y4 = mysaturationlist y5 = myvaluelist 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -