【问题标题】:how to set the vertical scale of pyplot linear figure如何设置pyplot线性图的垂直比例
【发布时间】:2023-04-02 01:16:01
【问题描述】:

我有一个代码,使用 plotly 在 python 中显示地质井日志, 比例是线性的,我根据数据帧索引设置它的范围 我需要将比例保持为线性,但想将垂直比例或 y 轴比例设置为例如 1:100 如何实现这一点

layout = go.Layout(
    title='VSH',
    autosize=False,
    width=500,
    height=1500,
    yaxis=dict(
        title='DEPT',
        showgrid=True,
        showticklabels=True,
        gridcolor='#bdbdbd',
        gridwidth=2
    ),
    xaxis=dict(
        title='Vsh',
        showgrid=True,
        showticklabels=True,
        gridcolor='#bdbdbd',
        gridwidth=2
    )
)

df = df.loc[(df.index >= int(top)) & (df.index <= int(base))]
trace1 = go.Scatter(x = df['Vsh']/10 , y = df.index , mode='lines')
fig = go.Figure(data=[trace1] , layout = layout)
iplot(fig)

【问题讨论】:

    标签: python plotly


    【解决方案1】:

    只需创建一个列表(例如,从 1 到 100):

    list1 = [i for i in range(0, 101)]
    

    并在layout中为yaxis添加了两个参数:

    yaxis=dict(tickvals=[i for i in range(len(list1))],
               ticktext=list1)
    

    您可以在 plotly 文档中阅读更多关于 ticktexttickvals 的信息:12

    【讨论】:

      猜你喜欢
      • 2015-07-26
      • 2023-03-20
      • 1970-01-01
      • 1970-01-01
      • 2019-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-02
      相关资源
      最近更新 更多