2015-05-27 45 views
0

如何使用Plotly生成此類型的「浮動棒」(或「高/低」?)圖表?我仔細看過這些例子,找不到任何相同的東西 - 最重要的是設置不從零開始的條/棒。Plotly中的浮動棒圖

請注意,行不是錯誤欄。

Example plot

回答

2

的一種方式,使棍的圖表是與asymmetric error barszero width負偏移。這裏有一個例子:

import plotly.plotly as py 
from plotly.graph_objs import ErrorY, Scatter 

x = [1, 2, 3, 4] 
y = [4, 7, 5, 9] 
stick_top = [10, 6, 7, 11] 
stick_bottom = [6, 4, 3, 4] 

error_bar_positive_offset = [si - yi for (yi, si) in zip(y, stick_top)] 
error_bar_negative_offset = [yi - si for (yi, si) in zip(y, stick_bottom)] 

py.plot([ 
    Scatter(x=x, y=y, mode='markers', 
     error_y=ErrorY(
      symmetric=False, 
      array=error_bar_positive_offset, 
      arrayminus=error_bar_negative_offset, 
      width=0 
     ) 
    )], filename='stick-chart') 

Stick chart made with Plotly https://plot.ly/~chris/15416