Reputation: 597
I trying to change the color of filled shape and add image logo on the top left and price on the right but I don't want price and logo overlapping chart at self, is there is way to move it up?
My code:
def chartBuilber(self):
df: DataFrame = pd.DataFrame.from_dict(self.priceHistory()).fillna(method="backfill")
df.set_index('Date', inplace=True)
df = df.astype(float)
market_colors = mpf.make_marketcolors(
base_mpf_style="yahoo"
)
rc = {
"axes.labelcolor": "none",
"axes.spines.bottom": True,
"axes.spines.left": False,
"axes.spines.right": False,
"axes.spines.top": False,
"font.size": 12,
}
styles = mpf.make_mpf_style(
base_mpf_style="nightclouds",
marketcolors=market_colors,
gridstyle="",
rc=rc
)
mpf.plot(df, type='line',
title='Test',
linecolor='#00ff00',
style=styles,
volume=True,
figsize=(18, 12),
figscale=0.5,
fill_between=df['Close'].values,
tight_layout=True,
scale_padding={'left': 0.5, 'top': 5, 'right': 0.7, 'bottom': 1})
Upvotes: 2
Views: 547
Reputation: 7714
To change the color of the fill, you can specify fill_between
as a dict
(instead of list of numbers). In the dict you must specify y1=
for the y values (for example, in your case, y1=df['Close'].values
). Then add also to the dict facecolor=
the color you want for the fill. Thus, something like:
mpf.plot(df,...,fill_between=dict(y1=df['Close'].values`,facecolor='lime'),...)
To get some extra room at the top of the plot, you can use kwarg ylim=
specifying a two-element tuple or list (ymin,ymax) where ymax is enough larger than your maximum y-value to give you the amount of space your desire.
Upvotes: 2