Matplotlib plt.fill_between 'isinfinite' ошибка - PullRequest
0 голосов
/ 23 июня 2018

У меня есть этот код:

g1 = plt.plot(centers[0],'-',label=u'Group 1',color='#1f77b4')
g1_max = plt.plot(centers[0]+max_g1,'-',color='#1f77b4',alpha=0.5)
plt.fill_between(range(len(g1)),g1,g1_max,facecolor='#1f77b4',alpha=0.5)

И я получаю следующую ошибку:

TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

Любая подсказка, почему? Спасибо

1 Ответ

0 голосов
/ 23 июня 2018

plt.fill_between используется здесь неправильно, x, y1 и y2 должны быть списками, а не генераторами или графическими объектами (см. https://matplotlib.org/api/_as_gen/matplotlib.pyplot.fill_between.html). Вероятно, будет работать следующее:

import numpy as np

g1 = plt.plot(centers[0],'-',label=u'Group 1',color='#1f77b4')
g1_max = plt.plot(centers[0]+max_g1,'-',color='#1f77b4',alpha=0.5)
plt.fill_between(np.arange(len(g1)),centers[0],centers[0]+g1_max,facecolor='#1f77b4',alpha=0.5)
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...