matplotlib / mplfinance is it possible to add a title to the plot?

Viewed 2027

I have made a plot with mplfinance: enter image description here

Is it possible to add an title to the mplfinance plot(like plt.title(stock)? Or is it possible a chart like that with matplotlib?

apdict = [mpf.make_addplot(df[['ema34High','ema34Low']],color='y',linestyle='dashdot'),
      mpf.make_addplot(df[['SMA10High','SMA8Low']],color='b',linestyle='dashdot'),
     ]
mpf.plot(df,volume=True,addplot=apdict,style='starsandstripes',datetime_format=' %A, %d- 
%m',xrotation=45)enter code here
2 Answers

@DavidG's comment to the question is the answer:

"Add a title kwarg in the call to plot

mpf.plot(df, ..., title="My Title")
# libraries
import numpy as np
import matplotlib.pyplot as plt
 
# create dataset
height = [3, 12, 5, 18, 45]
bars = ('A', 'B', 'C', 'D', 'E')
x_pos = np.arange(len(bars))
 
# Create bars and choose color
plt.bar(x_pos, height, color = (0.5,0.1,0.5,0.6))
 
# Add title and axis names
plt.title('My title')
plt.xlabel('categories')
plt.ylabel('values')
 
# Create names on the x axis
plt.xticks(x_pos, bars)
 
# Show graph
plt.show()
Related