Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 21a18ce

Browse files
authored
Merge pull request plotly#831 from plotly/layout-images-on-subplots
Layout images on subplots
2 parents 90de27b + 8fb9134 commit 21a18ce

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

src/components/images/draw.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@ module.exports = function draw(gd) {
104104
height = yref ? Math.abs(yref.l2p(d.sizey) - yref.l2p(0)) : d.sizey * size.h;
105105

106106
// Offsets for anchor positioning
107-
var xOffset = width * anchors.x[d.xanchor].offset + size.l,
108-
yOffset = height * anchors.y[d.yanchor].offset + size.t;
107+
var xOffset = width * anchors.x[d.xanchor].offset,
108+
yOffset = height * anchors.y[d.yanchor].offset;
109109

110110
var sizing = anchors.x[d.xanchor].sizing + anchors.y[d.yanchor].sizing;
111111

112112
// Final positions
113-
var xPos = (xref ? xref.l2p(d.x) : d.x * size.w) + xOffset,
114-
yPos = (yref ? yref.l2p(d.y) : size.h - d.y * size.h) + yOffset;
113+
var xPos = (xref ? xref.l2p(d.x) + xref._offset : d.x * size.w + size.l) + xOffset,
114+
yPos = (yref ? yref.l2p(d.y) + yref._offset : size.h - d.y * size.h + size.t) + yOffset;
115115

116116

117117
// Construct the proper aspectRatio attribute

test/image/baselines/layout_image.png

-14.5 KB
Loading

test/image/mocks/layout_image.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,19 @@
33
{
44
"x": [1,2,3],
55
"y": [1,2,3]
6+
}, {
7+
"x": [1,2,3],
8+
"y": [1,2,3],
9+
"yaxis": "y2"
610
}
711
],
812
"layout": {
13+
"yaxis": {
14+
"domain": [0, 0.5]
15+
},
16+
"yaxis2": {
17+
"domain": [0.5, 1]
18+
},
919
"images": [
1020
{
1121
"source": "https://images.plot.ly/language-icons/api-home/python-logo.png",
@@ -32,7 +42,7 @@
3242
{
3343
"source": "https://images.plot.ly/language-icons/api-home/r-logo.png",
3444
"xref": "x",
35-
"yref": "y",
45+
"yref": "y2",
3646
"x": 1,
3747
"y": 3,
3848
"sizex": 2,

0 commit comments

Comments
 (0)