-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
I cannot seem to find a way to set a numerical axis as categorical in a subplot.
In a normal graph i would just use fig.update_layout(xaxis_type = 'category')
But update_layout does not have a row, col parameter. So... how do i set that for a specific trace?
add_trace doesn't seem to have any layout options either.
Is this just not implemented?
Adding the xaxis as a str doesn't help either, as it is converted to integer. Even adding an empty space doesn't work. x = [str(-k)+' ' for k in range(0,10)]
I would have to add some sort of letter to the name.
Which would work, it's just that since the functionality for categorical axes is implemented i would think that it would be available for subplots as well.
Here's a basic subplot graph:
from plotly.subplots import make_subplots
import plotly.graph_objects as go
fig = make_subplots(rows = 2, cols = 2, subplot_titles=['Subplot1', 'Subplot2'],
specs=[[{}, {"rowspan": 2},]]+[[{},None]],
column_widths= [0.7,0.3]
)
fig.add_trace(
go.Bar(y = [k for k in range(0,10)], x = [k for k in range(0,10)],orientation='h' ),
row = 1, col = 1,
)
fig.add_trace(
go.Bar(y = [-k for k in range(0,10)], x = [k for k in range(0,10)] ,),
row = 1, col = 2,
)
fig.add_trace(
go.Bar(y = [k for k in range(0,10)], x = [k for k in range(0,10)] ),
row = 2, col = 1,
)
fig.show()
I've tried adding an entire Figure with add_trace, so i can define the layout as i add it, but that just results in an error.
Any help is appreciated :)