I have a plot which looks like:

The x-axis is shared and the y-axes are not. I currently have a code which when double-clicking a trace in the legend will delete the other two traces and show only the one trace. Here is the relevant code:
var myPlot = document.getElementById('graph');
myPlot.on('plotly_legenddoubleclick', function(data){
var trace = data.curveNumber + 1;
if (trace == 1 && flag2 == 0) {
var layout_update = {title: "Historical Trend", autosize: true, xaxis: {title:"Date", type: "date", rangeselector: {buttons: [{count: 1,label: '1m',step: 'month',stepmode: 'backward'},{count: 3,label: '3m',step: 'month',stepmode: 'backward'},{count: 6,label: '6m',step: 'month',stepmode: 'backward'},{step: 'all'}]}},yaxis: {title:"Vertical",fixedrange: true}};
Plotly.update('graph', layout_update);
Plotly.deleteTraces('graph', 1);
Plotly.deleteTraces('graph', 1);
flag2 = 1;
}
else if (trace == 2 && flag2 == 0) {
var layout_update = {title: "Historical Trend", autosize: true, xaxis: {title:"Date", type: "date", rangeselector: {buttons: [{count: 1,label: '1m',step: 'month',stepmode: 'backward'},{count: 3,label: '3m',step: 'month',stepmode: 'backward'},{count: 6,label: '6m',step: 'month',stepmode: 'backward'},{step: 'all'}]}},yaxis: {title:"Horizontal",fixedrange: true}};
Plotly.update('graph', layout_update);
Plotly.deleteTraces('graph', 0);
Plotly.deleteTraces('graph', 1);
flag2 = 1;
}
else if (trace == 3 && flag2 == 0) {
var layout_update = {title: "Historical Trend", autosize: true, xaxis: {title:"Date", type: "date", rangeselector: {buttons: [{count: 1,label: '1m',step: 'month',stepmode: 'backward'},{count: 3,label: '3m',step: 'month',stepmode: 'backward'},{count: 6,label: '6m',step: 'month',stepmode: 'backward'},{step: 'all'}]}},yaxis: {title:"Axial",fixedrange: true}};
Plotly.update('graph', layout_update);
Plotly.deleteTraces('graph', 0);
Plotly.deleteTraces('graph', 0);
flag2 = 1;
}
});
I want to include a clause with flag == 1 that will return the view to the 3 plot view. How can I do this?