Skip to content

Commit ddfd23d

Browse files
authored
Merge pull request #1110 from plotly/subplots-with-layout-grids
Subplots with layout grids
2 parents 63cc683 + e5a98e1 commit ddfd23d

7 files changed

+35
-56
lines changed

_posts/plotly_js/basic/pie/2015-08-10-donut-chart.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
var data = [{
1212
values: [16, 15, 12, 6, 5, 4, 42],
1313
labels: ['US', 'China', 'European Union', 'Russian Federation', 'Brazil', 'India', 'Rest of World' ],
14-
domain: {
15-
x: [0, .48]
16-
},
14+
domain: {column: 0},
1715
name: 'GHG Emissions',
1816
hoverinfo: 'label+percent+name',
1917
hole: .4,
@@ -23,7 +21,7 @@
2321
labels: ['US', 'China', 'European Union', 'Russian Federation', 'Brazil', 'India', 'Rest of World' ],
2422
text: 'CO2',
2523
textposition: 'inside',
26-
domain: {x: [.52, 1]},
24+
domain: {column: 1},
2725
name: 'CO2 Emissions',
2826
hoverinfo: 'label+percent+name',
2927
hole: .4,
@@ -52,8 +50,10 @@
5250
y: 0.5
5351
}
5452
],
55-
height: 600,
56-
width: 600
53+
height: 400,
54+
width: 600,
55+
showlegend: false,
56+
grid: {rows: 1, columns: 2}
5757
};
5858

5959
Plotly.newPlot('myDiv', data, layout);

_posts/plotly_js/basic/pie/2015-08-10-pie-chart-subplots.html

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
sitemap: false
88
arrangement: horizontal
99
markdown_content: |
10-
In order to create pie chart subplots, you need to use the [domain](https://plot.ly/javascript/reference/#pie-domain) attribute. It is important to note, that the `X` array sets the horizontal position whilst the `Y` array sets the vertical. For example, `x: [0,0.5], y : [0,0.5]` would mean the bottom left position of the plot.
10+
In order to create pie chart subplots, you need to use the [domain](https://plot.ly/javascript/reference/#pie-domain) attribute. `domain` allows you to place each trace on a [grid](https://plot.ly/javascript/reference/#layout-grid) of rows and columns defined in the layout or within a rectangle defined by `X` and `Y` arrays. The example below uses the `grid` method (with a 2 x 2 grid defined in the layout) for the first three traces and the X and Y method for the fourth trace.
1111
---
1212

1313
var allLabels = ['1st', '2nd', '3rd', '4th', '5th'];
@@ -35,8 +35,8 @@
3535
colors: ultimateColors[0]
3636
},
3737
domain: {
38-
x: [0, .48],
39-
y: [0, .49]
38+
row: 0,
39+
column: 0
4040
},
4141
hoverinfo: 'label+percent+name',
4242
textinfo: 'none'
@@ -49,8 +49,8 @@
4949
colors: ultimateColors[1]
5050
},
5151
domain: {
52-
x: [0.52, 1],
53-
y: [0, .49]
52+
row: 1,
53+
column: 0
5454
},
5555
hoverinfo: 'label+percent+name',
5656
textinfo: 'none'
@@ -63,8 +63,8 @@
6363
colors: ultimateColors[2]
6464
},
6565
domain: {
66-
x: [0, .48],
67-
y: [.51, 1]
66+
row: 0,
67+
column: 1
6868
},
6969
hoverinfo: 'label+percent+name',
7070
textinfo: 'none'
@@ -77,16 +77,17 @@
7777
colors: ultimateColors[3]
7878
},
7979
domain: {
80-
x: [0.52, 1],
81-
y: [0.52, 1]
80+
x: [0.52,1],
81+
y: [0, 0.48]
8282
},
8383
hoverinfo: 'label+percent+name',
8484
textinfo: 'none'
8585
}];
8686

8787
var layout = {
8888
height: 400,
89-
width: 500
89+
width: 500,
90+
grid: {rows: 2, columns: 2}
9091
};
9192

9293
Plotly.newPlot('myDiv', data, layout);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
permalink: javascript/subplot-charts/
3+
redirect_to: javascript/#multiple-axes-subplots-and-insets
4+
sitemap: false
5+
---
6+

_posts/plotly_js/subplot/subplots/2015-04-09-multiple-subplots.html

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,7 @@
4040
var data = [trace1, trace2, trace3, trace4];
4141

4242
var layout = {
43-
xaxis: {domain: [0, 0.45]},
44-
yaxis: {domain: [0, 0.45]},
45-
xaxis4: {
46-
domain: [0.55, 1],
47-
anchor: 'y4'
48-
},
49-
xaxis3: {
50-
domain: [0, 0.45],
51-
anchor: 'y3'
52-
},
53-
xaxis2: {domain: [0.55, 1]},
54-
yaxis2: {
55-
domain: [0, 0.45],
56-
anchor: 'x2'
57-
},
58-
yaxis3: {domain: [0.55, 1]},
59-
yaxis4: {
60-
domain: [0.55, 1],
61-
anchor: 'x4'
62-
}
43+
grid: {rows: 2, columns: 2, pattern: 'independent'},
6344
};
6445

6546
Plotly.newPlot('myDiv', data, layout);

_posts/plotly_js/subplot/subplots/2015-04-09-shared-axes-subplots.html

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,11 @@
4141
var data = [trace1, trace2, trace3, trace4];
4242

4343
var layout = {
44-
xaxis: {domain: [0, 0.45]},
45-
yaxis: {domain: [0, 0.45]},
46-
xaxis4: {
47-
domain: [0.55, 1],
48-
anchor: 'y4'
49-
},
50-
xaxis2: {domain: [0.55, 1]},
51-
yaxis3: {domain: [0.55, 1]},
52-
yaxis4: {
53-
domain: [0.55, 1],
54-
anchor: 'x4'
44+
grid: {
45+
rows: 2,
46+
columns: 2,
47+
subplots:[['xy','x2y'], ['xy3','x4y4']],
48+
roworder:'bottom to top'
5549
}
5650
};
5751

_posts/plotly_js/subplot/subplots/2015-04-09-simple-subplot.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@
2525
var data = [trace1, trace2];
2626

2727
var layout = {
28-
xaxis: {domain: [0, 0.45]},
29-
yaxis2: {anchor: 'x2'},
30-
xaxis2: {domain: [0.55, 1]}
28+
grid: {rows: 1, columns: 2, pattern: 'independent'},
3129
};
3230

3331
Plotly.newPlot('myDiv', data, layout);

_posts/plotly_js/subplot/subplots/2015-04-09-stacked-subplots.html

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,11 @@
3232
var data = [trace1, trace2, trace3];
3333

3434
var layout = {
35-
yaxis: {domain: [0, 0.266]},
36-
legend: {traceorder: 'reversed'},
37-
xaxis3: {anchor: 'y3'},
38-
xaxis2: {anchor: 'y2'},
39-
yaxis2: {domain: [0.366, 0.633]},
40-
yaxis3: {domain: [0.733, 1]}
35+
grid: {
36+
rows: 3,
37+
columns: 1,
38+
pattern: 'independent',
39+
roworder: 'bottom to top'}
4140
};
4241

4342
Plotly.newPlot('myDiv', data, layout);

0 commit comments

Comments
 (0)