I am trying a plot in a div using plotly.js which is a bit large in height. I want to fit it to div's height. If I use
<div id="plotDiv"></div>
and
var trace1 = {
x: ['giraffes', 'orangutans', 'monkeys'],
y: [20, 14, 23],
name: 'SF Zoo',
type: 'bar'
};
var trace2 = {
x: ['giraffes', 'orangutans', 'monkeys'],
y: [12, 18, 29],
name: 'LA Zoo',
type: 'bar'
};
var data = [trace1, trace2];
var layout = {
autosize:true,
barmode: 'stack',
xaxis: {
tickangle: -45
},
};
Plotly.newPlot('plotDiv', data, layout);
The plot is a bit large in height, so i put a max-height in div, this way :
<div id="plotDiv" style="max-height:300px"></div>
But this doesn't fit the plot in the div, and hides some of the plot. How to fit the complete plot in the div?