定制yaxis

问题描述 投票:0回答:1

是否可能使轴“断裂”或间隔不均匀?例如,假设我有数据围绕y = [0,100]和一些异常值,例如500,1000等 从0到1000显示将隐藏详细信息。 我可以显示y = 0-100,然后y = 800-1000的数据,并且轴间距等是否会中断? 我已经尝试了枚举的tickvals和ticktext,但它似乎不起作用。

plotly plotly-dash
1个回答
0
投票

您可以使用子图创建您想要的东西,但这是一个非常难看的解决方案。

码:

# import all the necessaries libraries
import plotly.offline as pyo
import plotly.graph_objs as go
from plotly import tools

# specify traces
trace1 = go.Bar(
    x=[1, 2, 3],
    y=[500, 1100, 1500],
    xaxis='x1',
    yaxis='y1')
trace2 = go.Bar(
    x=[1, 2, 3],
    y=[500, 1100, 1500],
    xaxis='x2',
    yaxis='y2')
trace3 = go.Bar(
    x=[1, 2, 3],
    y=[500, 1100, 1500],
    xaxis='x3',
    yaxis='y3')

# create data (list with traces)
data = [trace1, trace2, trace3]

# Specify layout
layout = go.Layout(
    height=600, width=600,
    # Select each yaxis and manually set domain (where on screen it will place)
    yaxis1=dict(range=[400, 600], domain=[0, 0.25]),
    yaxis2=dict(range=[1000, 1200], domain=[0.35, 0.60]),
    yaxis3=dict(range=[1400, 1600], domain=[0.70, 0.95])
    )

# Create figure
fig = go.Figure(data=data, layout=layout)

# Plot the plot
pyo.plot(fig, filename='try-axis-plot.html')

输出:

You see that?

谷歌搜索后,我决定,plotly中的“断裂”轴是不允许的,如here所述

© www.soinside.com 2019 - 2024. All rights reserved.