Skip to content

Commit 27d80be

Browse files
committed
explain grid subplots and add examples in pie charts examples
1 parent b4c52a5 commit 27d80be

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
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` 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);

0 commit comments

Comments
 (0)