Hi
I am trying to plot a bar chart.
my dataframe is like
df = pd.DataFrame({
'direct': ['offer', 'offer', 'bid', 'bid'],
'price': [100, 99, 98, 97],
'qty': [10000, 213, 99, 123],
'color': ['red', 'red', 'green', 'green']
})
The code to plot bar chat is like
# RENDER ORDER BOOK CHART !
def render_ask_chart(df):
chart = go.Figure(
data=[go.Bar(
x=df['qty'],
y=df['price'],
marker_color=df['color'],
orientation='h',
width=0.3,
textposition='outside',
insidetextfont=dict(family='Times', size=13, color='white'),
showlegend=False),
],
layout=go.Layout(
xaxis=dict(autorange="reversed", title=dict(text='Volume', font=dict(size=50)),
tickfont_size=28),
yaxis=dict(title='PRICE', side='right'),
)
)
chart.update_layout(barmode='stack',
height=800, margin=dict(t=0,b=0,l=0,r=0))
return chart
The code works fine and the bar chat looks like below.
However, I also want to change the color of unit font in Y axis. I want to change color of axis unit in βOfferβ area into βredβ . i.e. numbers 265, 270, 275, 280 and 285 into red color. Like the following.
Also I want axis unit in βBidβ area into βgreenβ, i.e. numbers 260, 255 and 250 into green color.
What syntax should I add to layout ? Thanks.