【发布时间】:2019-08-03 09:42:17
【问题描述】:
下面是我要绘制的散点图的代码。绘制子图后,我想添加一条相关线。尽管代码运行没有错误,但我看不到图中绘制的任何线条。任何帮助将不胜感激。
fig, ax = plt.subplots(figsize=fs)
for g in np.unique(group):
ix = np.where(group == g)
sc = ax.scatter(y[ix], dosage[ix], color = cdict[g], edgecolors='none')
# Fit with polyfit
b, m = polyfit(y, dosage, 1)
ax.plot(y, b + m * y, '-')
ax.set_xlabel('LT2', fontsize = 16)
ax.set_ylabel('Log Dosage', fontsize = 16)
# ax.legend(scatterpoints = 1, title='DILI Risk')
# fig.colorbar(sc, label='Dosage/mg/day')
path_dose = 'figure/reports/images/{}_hist_dose.png'.format(name_rep)
data['hist_dosage'].append(path_dose)
plt.savefig(path_dose)
plt.close()
【问题讨论】:
-
也许matplotlib.org/api/_as_gen/matplotlib.pyplot.xcorr.html 的文档在 matplotlib 中讨论 xcorr 会很有用
-
无法访问您的数据,也无法查看您的情节,我们无法告诉您出了什么问题
-
最好在您的问题中添加一个小型(虚构)数据集。
标签: python matplotlib correlation scatter-plot