Reverse and move axes in Plotly - iplot

89 Views Asked by At

How does one reserve and move axes in plotly interactive iplots? I have tried the following to the code below but with no luck.

fig['layout']['yaxis']['autorange'] = "reversed"

import ipywidgets as widgets
from ipywidgets import interact, interact_manual

@interact
def scatter_plot(x=list(df.select_dtypes('number').columns), 
         y=list(df.select_dtypes('number').columns)[1:],
         theme=list(cf.themes.THEMES.keys()), 
         colorscale=list(cf.colors._scales_names.keys())):

 df.iplot(kind='scatter', x=x, y=y, mode='markers', 
     xTitle=x.title(), yTitle=y.title(),
     title=f'{y.title()} vs {x.title()}',
    theme=theme, colorscale=colorscale)
1

There are 1 best solutions below

0
On

The variable fig should be assigned to plotly objects. An example of reversing the y-axis using Plotly

import plotly.graph_objects as go
import numpy as np

t = np.linspace(0, 5, 200)
y = np.sin(t)

fig = go.Figure(data=go.Scatter(x=t, y=y, mode='markers'))
fig['layout']['yaxis']['autorange'] = "reversed"

fig.show()

enter image description here