【问题标题】:Reverse and move axes in Plotly - iplot在 Plotly 中反转和移动轴 - iplot
【发布时间】:2021-09-10 00:46:54
【问题描述】:

如何在情节交互的 iplot 中保留和移动轴? 我已经尝试了以下代码,但没有运气。

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)

【问题讨论】:

    标签: python plotly scatter-plot iplots


    【解决方案1】:

    变量 fig 应该分配给 plotly 对象。使用 Plotly 反转 y 轴的示例

    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()

    【讨论】:

      猜你喜欢
      • 2020-12-15
      • 1970-01-01
      • 1970-01-01
      • 2019-02-24
      • 1970-01-01
      • 1970-01-01
      • 2022-01-19
      • 2021-02-23
      • 2023-03-06
      相关资源
      最近更新 更多