newPlot vs addTraces + relayout
by Ariel Balter
HTML
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<div id="graph"></div>
JavaScript
Plotly.newPlot("graph",[],{title: "Plot"});
trace1 = {y: [1,2,1]};
trace2 = {
y: [0,0,0],
yaxis: "y2",
mode: "markers",
marker: {symbol: 6, size: 12}
};
yaxis1 = {domain: [0, 0.8], title: "one"};
yaxis2 = {
domain: [0.85, 1.0],
showgrid: false,
showticklabels: false,
title: "two",
zeroline: false
};
Plotly.relayout('graph', {yaxis1});
Plotly.addTraces('graph', [trace1]);
Plotly.relayout('graph', {yaxis2});
Plotly.addTraces('graph', [trace2]);
//Plotly.newPlot('graph',[trace1, trace2],{yaxis1, yaxis2});