使用plotly框架在3D轴上绘制日期

时间:2018-10-03 21:47:50

标签: javascript python graph plotly

我在日历中使用值作为Y轴上的字符串“ 2010-01-11”,“ 2010-01-12”,“ 2010-01-13”,并且比这还给我带来了这样的效果:

Image without hour and minutes

但是当我将字符串更改为'2010-01-11 11:00:00','2010-01-11 11:30:00','2010-01-11 11:45:00' >

轴从中心向左移动。

Graph with hour and minute

我正在使用的代码:

      var trace1 = {
      x: xData[0],
      y: yData[0],
      z: zData[0],
      ycalendar: 'gregorian',
      mode: 'lines',
      marker: {
        color: '#1f77b4',
        size: 12,
        symbol: 'circle',
        line: {
          color: 'rgb(0,0,0)',
          width: 0
        }},
      line: {
        color: '#1f77b4',
        width: 2
      },
      type: 'scatter3d'
    };

    var trace2 = {
      x: xData[1],
      y: yData[1],
      z: zData[1],
      ycalendar: 'gregorian',
      mode: 'lines',
      marker: {
        color: '#9467bd',
        size: 12,
        symbol: 'circle',
        line: {
          color: 'rgb(0,0,0)',
          width: 0
        }},
      line: {
        color: 'rgb(44, 160, 44)',
        width: 2
      },
      type: 'scatter3d'
    };

    var trace3 = {
      x: xData[2],
      y: yData[2],
      z: zData[2],
      ycalendar: 'gregorian',
      mode: 'lines',
      marker: {
        color: '#bcbd22',
        size: 12,
        symbol: 'circle',
        line: {
          color: 'rgb(0,0,0)',
          width: 0
        }},
      line: {
        color: '#bcbd22',
        width: 2
      },
      type: 'scatter3d'
    };

    var data = [trace1, trace2, trace3];
    var layout = {
      title: '3D Line Plot',
      autosize: false,
      width: 1200,
      height: 800,
      scene: {
        aspectratio: {
          x: 1,
          y: 1,
          z: 0.5,
       },
         yaxis: {
            autorange: true,
            type: 'date',
            range:['2018-01-11 11:00:00.00', '2018-01-11 11:50:00.00']
        },
      },
      margin: {
        l: 0,
        r: 0,
        b: 0,
        t: 65
      }
    };
    Plotly.newPlot('myDiv', data, layout);

你们知道我该怎么做才能将y轴与z和x放在一起吗?

0 个答案:

没有答案