Matplotlib соединяет точки рассеяния с линией - PullRequest
0 голосов
/ 03 мая 2020

Я прочитал вопрос Matplotlib соединяет точки рассеяния с линией - Python, но у меня это не работает ...

Я пытался использовать plt.scatter(x, y) и после этого plt.show(), но все, что я вижу, это набор отделенных друг от друга точек.

Like that:

Я думаю, что проблема заключается в том, что я использую al oop для генерации каждой точки на графике и после этого l oop, я использую plt.show().

Весь мой код выглядит так:

x = 0
y = 0
def eye_gaze1(a,b):
    global x,y
    image_plot1 = plt.imshow(image1)
    for i in range(len(a)):
        if stimulus_name[x+y+1] == '5_01.jpg' and a[x+y+1] != '-':
            plt.scatter([a[x+y+1]], [b[x+y+1]]) #here I putting new point on the image_plot1 and this process repeats (something like 1000 times) before in my massive of data cycle will find '-' symbol
            x += 1
        else:
            x += 1
            break

    plt.show() #final image
    y += x
    x = 0

j = 0    
while j < 15: #just repeat this function for another cells in data-massive 
    eye_gaze1(col_values_X_right,col_values_Y_right) 
    j += 1

Итак, вопрос в том, как я могу соединить точки?


Если я пытаюсь использовать комментарий Йохана C, я вижу эту ошибку: TypeError: ufunc 'sqrt' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

x = 0
y = 0
def eye_gaze1(a,b):
    global x,y
    image_plot1 = plt.imshow(image1)
    for i in range(len(a)):
        if stimulus_name[x+y+1] == '5_01.jpg' and a[x+y+1] != '-':
            X_coordinates = list().append(a[x+y+1])
            Y_coordinates = list().append(b[x+y+1])

            x += 1
        else:
            x += 1
            break
    plt.scatter(X_coordinates, Y_coordinates, '-o')    
    plt.show()
    y += x
    x = 0

j = 0    
while j < 15:
    eye_gaze1(col_values_X_right,col_values_Y_right)
    print(x)
    print(y)
    j += 1

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...