How can I annotate a scatter-line plot with data corresponding to Y column?

13 Views Asked by At

I want to prepare a scatter + line plot where the data corrresponding to Y columns are annotated on each pdata point of the plot. The plot is X,Y, 1 x column and 3 Y columns. I am using the following script. I have searched how to do this in various forums but I can't find the right way of doing it. I would greatly appreciate your help. Thanks in advance :)


  #Plot title
plt.title("CO$_{2}$ Removal Efficiency at Different CO$_{2}$ concentration")

file.plot(x="Co2 concentration (%)",
          y=file.columns.difference(["Co2 concentration (%)"]),
          ax=plt.gca(), marker="o", figsize=(8, 6))



plt.grid()

# plt.legend()

plt.legend(bbox_to_anchor =(0, -0.2, 1, 0.5), loc="lower center",mode = 'expand', ncol=4, facecolor='white', framealpha=1, frameon=False)

    
#Axis labels
plt.xlabel('CO$_{2}$ concentration (%)')
plt.ylabel('CO$_{2}$ removal efficiency (%)')

**# Iterate through each column (excluding X-axis column)
# for column in file.columns.difference(["Co2 concentration (%)"]):
    # Annotate points with Y-axis values
#     for index, value in enumerate(file[column]):
#         file.plot.annotate((file["Co2 concentration (%)"][index], value), textcoords="offset points", xytext=(0,10), ha='center')
**

plt.ylim(10, 110)

plt.tight_layout()

#Save the plot in the folder where the kernel is saved
plt.savefig('CO2_removal.jpeg', dpi=300)
0

There are 0 best solutions below