在Plotly

时间:2017-09-19 21:03:29

标签: matplotlib plot plotly ggplotly

我的布局有以下代码:

    var layout = {
        title:"Energy usage of green electrical appliances",
        plot_bgcolor:"#000",
        paper_bgcolor:"#000",
        showlegend:false,
        margin:"{l: 40, b: 40, r: 80, t: 40,}",
        xaxis:{
          title:"Date/Time",
          autoscale:"true",
          rangeselector: {
            bgcolor:"#555",
        },
        yaxis:{
          title:"Price",
          autoscale:"true",
          overlaying:"y2",
          side:"left",
        },
        yaxis2: {
          title:"Electricity Used",
          autoscale:"true",
          side:"right"
        },
        yaxis3:{
          title:"AiJ/day",
          autoscale:"true",
          side:right
        }
     }

以及我的数据的以下代码:

        var tracePrice=                {name:"Price",type:"scatter",x:output[0]["datetime"],y:output[0]["price"],line:{color:"orange",width:2},};
        var traceElecUsed=                {name:"Elec",type:"bar",x:output[0]["datetime"],y:output[0]["Elec"],line:{color:"cyan",width:2},};
        var traceAiJ=           {name:"aij",type:"scatter",x:output[0]["datetime"],y:output[1]["aijpercent"],yaxis:"y2",marker:{color:"#fff"},line:{color:"#555",width:1}};
        return resolve([tracePrice,traceElecUsed,traceAiJ]);

问题是,一切正常,直到我绘制traceElecUsed。它使用的单位数以千计,而价格通常低于5英镑,而AiJ则为0-100%。我不知道这是否是问题的根源。如果我删除它一切正常。

1 个答案:

答案 0 :(得分:0)

stackoverflow诅咒再次让我失望;我用了一些东西挣扎了几个小时,然后一旦我发布了答案就出现了。

对于将来需要此信息的人,它依赖于“覆盖”

    yaxis3: {
      title:"Aij",
      autoscale:"true",
      overlaying:"y2",
      side:"right"
    }