- I wish to NOT show the inner category label in a multi-catogory bar chart using plotly graph-objects
- Further, I wish to rotate the label of the outer category label
This is my code
import pandas as pd
import plotly.graph_objects as go
df = pd.DataFrame({
"City": ["Toronto", "Toronto", "Toronto", "CPH", "CPH", "London", "London"],
"Tower name": ["T1", "T2", "T3", "T4", "T5", "T6","T7"],
"Height": [1.0, 1.5, 2.0, 3.0, 4.0, 2.0 ,5.0],
})
fig = go.Figure(go.Bar(x=df.loc[:,["City", "Tower name"]].T.values, y=df["Height"].values))
fig.show()
The code gives the following output:
Desired output is as shown below:
To hide the inner category I have tried to create an empty column in my data as follows, but that doesn't work
df['empty'] = ""
fig = go.Figure(go.Bar(x=df.loc[:,["City", "Tower name"]].T.values, y=df["Height"].values))
fig.update_xaxes(ticktext = df['empty'])
fig.show()
to rotate the tickmarks I have used tickangle, but that only rotates the inner category. The city names remain unrotated
fig = go.Figure(go.Bar(x=df.loc[:,["City", "Tower name"]].T.values, y=df["Height"].values))
fig.update_xaxes(tickangle = -90)
fig.show()
This is a follow-up questions to the thread: Remove empty bars in grouped plotly express bar chart, such that the visual distance between each group of bars is equal