1

Below is the code for the scatter plot that I am trying to draw. I want to add a correlation line once the subplots are drawn. Although the code is running without an error, I can't see any line drawn in the plot. Any help will be much appreciated.

    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()

Below is the plot that I am getting. enter image description here

Rohit Farmer
  • 319
  • 4
  • 15

1 Answers1

0

Sorry guys, I had nans in my data. np.polyfit() did not work at the first place and therefore there was nothing to plot.

Rohit Farmer
  • 319
  • 4
  • 15