2017-08-18 8 views
1

誰かが間違っていることを私に説明できたらそれを感謝しますか?線グラフをプロットする際のエラー

1)私はデータをポイントマーカー( 'r')または丸いマーカー( 'r。')だけでプロットすることができました。変更する線グラフでそれをプロットするには、以下の

はまた私のフィギュアを生成するコードと、私は以下のようにデータをコピーする必要があり

import cv2 
import numpy as np 
import matplotlib.pyplot as plt 


path = 'R:\\Temp\\xxx\\' 
path1 = 'R:\\Temp\\xxx\\' 

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 
for i in range(1770, 1869): # loop to auto-generate image names and run prior function 
    image_name = path + 'Cropped_Aligned_IMG_' + str(i) + '.png' # for loop runs from image number 1770 to 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) 


for k in range(1770,1869): 
    a = 'Cropped_Aligned_IMG_' + str(k) 
    image_name = path + a + '.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() 

をプリントアウトしたデータである(「R-」):

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] 
+0

を使用し、必要なリストを生成すること。第1の問題は、単一のリストではなく、リストのリスト内にある点に起因する。 2番目の問題は[この質問](https://stackoverflow.com/questions/27426668/row-titles-for-matplotlib-subplot)に示すように解決される可能性があります。 – ImportanceOfBeingErnest

答えて

3

データは、リスト。私。 [1,2,3]の代わりに[[1,2,3]]があります。 これはmatplotlibによって正しく理解されないので、点の間に線が引かれません。

正しくあなたは関係のない二つの質問を、持っている場合、2つの質問を

y = myBlueList 
x = myList 
y1 = myGreenList 
y2 = myRedList 
y3 = myHueList 
y4 = mySaturationList 
y5 = myValueList