3

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
Yvar
  • 155
  • 4
  • 14

3 Answers3

1

You can add title („My Title”) argument to the plot method:

mpf.plot(df, ..., title="My Title")

but you can also add axtitle („My Title”) argument instead

mpf.plot(df, ..., axtitle="My Title")

because it also appear above the chart and fits better than standard title.

PaulGilbert
  • 36
  • 1
  • 1
0

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

"Add a title kwarg in the call to plot

mpf.plot(df, ..., title="My Title")
Adnan S
  • 1,852
  • 1
  • 14
  • 19
-1
# 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()
Hütti
  • 60
  • 5