Skip to content

Commit 052c012

Browse files
committed
add automargin js tut
1 parent e79eed6 commit 052c012

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
name: Automatically Adjust Margins
3+
plot_url: https://codepen.io/plotly/embed/EdWVVy/?height=500&theme-id=15263&default-tab=result
4+
language: plotly_js
5+
suite: sizing
6+
order: 1
7+
sitemap: false
8+
arrangement: horizontal
9+
markdown_content: |
10+
Set `automargin=true` ([reference](https://plot.ly/python/reference/#layout-xaxis-automargin)) and Plotly will automatically increase the margin size to prevent ticklabels from being cut off or overlapping with axis titles.
11+
---
12+
var data = [
13+
{
14+
x: ['Apples', 'Oranges', 'Watermelon', 'Pears'],
15+
y: [3, 2, 1, 4],
16+
type: 'bar'
17+
}
18+
];
19+
var layout = {
20+
autosize: false,
21+
width: 500,
22+
height: 500,
23+
yaxis: {
24+
title: 'Y-axis Title',
25+
ticktext: ['long label','Very long label','3','label'],
26+
tickvals: [1, 2, 3, 4],
27+
tickmode: 'array',
28+
automargin: true,
29+
titlefont: { size:30 },
30+
},
31+
paper_bgcolor: '#7f7f7f',
32+
plot_bgcolor: '#c7c7c7'
33+
};
34+
Plotly.newPlot('myDiv', data, layout);

0 commit comments

Comments
 (0)