0

Hello I am trying to place a text right outside the graph where y = -100 is. The thing is the graph y and x values always change depending on the different numbers inputted within the code. A purple line is drawn at y= -100.

#Tittle, ylable, xlable 
plt.title('PnL in Accordense to Number of Trades', fontdict={'fontsize': 12})
plt.ylabel('PnL of the asset')
plt.xlabel('Number of trades')

#Plotting the PnL, Max_profit, Max_drawdown
PnL = plt.bar(x_indexes,bar_positions,width =width_bar, label= 'PnL')
Maximum_Profits = plt.bar(x_indexes+width_bar,Max_profit,width =width_bar, label= 'Max Upside', color ='green')
Maximum_Drawdown = plt.bar(x_indexes+width_bar*2,Max_drawdown,width =width_bar, label= 'Max Drawdown', color='red')
plt.axhline(-100, color = 'purple', linewidth =1.4, linestyle='--')

enter image description here enter image description here

1 Answers1

0

It's not possible to add labels outside the plotting area, it would be far easier to add a legend for the line to the graph. If you want it to be inline, there is an interesting workaround posted here: Inline labels in Matplotlib

Adi
  • 84
  • 5