I’m having problems with making axes visible in a plotly 3D chart. I would assume fig.update_xaxes(showline=True, linewidth=2, linecolor='black')
should do it but it is not having any effects, it looks like I’m missing something.
Additionally, I would like to display arrows for the axes.
import plotly.express as px
import numpy as np
import sys
from random import randint as rint
import pandas as pd
headers = ("Rank", "GMV", "Inventory", "Categories", "ETRS")
sellers = [(rint(20, 100), rint(500, 10000), rint(10, 200), rint(1, 6), rint(0, 1) == 1)
for _ in range(100)]
df = pd.DataFrame(sellers, columns=headers)
fig = px.scatter_3d(df, x='Inventory', y='Rank', z='GMV', size='Categories', color='ETRS')
fig.update_xaxes(showline=True, linewidth=2, linecolor='black')
fig.show()
Axes for 3d graphs are set in scene. Arrows were added with string annotations with no good results. Please refer to this reference.
import plotly.express as px
import numpy as np
import sys
from random import randint as rint
import pandas as pd
headers = ("Rank", "GMV", "Inventory", "Categories", "ETRS")
sellers = [(rint(20, 100), rint(500, 10000), rint(10, 200), rint(1, 6), rint(0, 1) == 1)
for _ in range(100)]
df = pd.DataFrame(sellers, columns=headers)
fig = px.scatter_3d(df, x='Inventory', y='Rank', z='GMV', size='Categories', color='ETRS')
fig.update_layout(
scene=dict(
xaxis=dict(showline=True, linewidth=3, linecolor='black'),
annotations=[
dict(
x=0,
y=100,
z=0,
text='>',
textangle=-45,
xanchor='left',
xshift=0,
# ax=-10,
# ay=150,
showarrow=False,
# arrowcolor='black',
# arrowsize=1,
# arrowwidth=2,
# arrowhead=1
)
]
))
fig.update_layout(height=600, margin=dict(t=0))
fig.show()
2