ich die Etiketten in meine Plots auf die Etiketten habe ich in meinem Diagramm sehen wollen, aber es funktioniert nicht:ändern Markennamen Python
sns.set(rc={"figure.figsize": (16, 8)})
ax = events_all_metrics[["event_name","kambi_payback"]].plot(x="event_name", style='.',use_index=False, color ='green', label='Kambi Payback')
events_all_metrics[["event_name","pinny_payback"]].plot(x="event_name",style='.', color='red', label='Pinnacle Payback', ax=ax)
plt.tick_params(
axis='x', # changes apply to the x-axis
which='both', # both major and minor ticks are affected
bottom='off', # ticks along the bottom edge are off
top='off', # ticks along the top edge are off
labelbottom='off')
plt.legend(loc=4, prop={'size': 15})
pinny_mean = events_all_metrics["pinny_payback"].mean()
plt.axhline(y=pinny_mean, label='Pinny Mean', linestyle='--', color='red')
kambi_mean = events_all_metrics["kambi_payback"].mean()
plt.axhline(y=kambi_mean, label='Kambi Mean', linestyle='--', color='green')
plt.show()
Also, habe ich herausgefunden, dass Im Grunde überschrieb plt.legend() die ursprünglichen Bezeichnungen in Pandas. Ich ging es bis zum Ende (kurz vor plt.show()) mit dem folgenden Code und es funktionierte:
plt.legend(["Kambi Payback","Pinnacle Payback", "Kambi Mean", "Pinnacle Mean"], loc=4, prop={'size': 15})
Wahrscheinlich weil die Zeile mit 'plt.legend (...)' am Ende sein sollte? – Georgy