Skip to content

Commit 1cb291e

Browse files
committed
fix plotly aspect ratios
1 parent 4528dc1 commit 1cb291e

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

Examples.ipynb

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@
396396
" 'x' : mpg['cty'],\n",
397397
"})\n",
398398
"fig.add_trace(hist)\n",
399-
"fig.show(renderer='png')"
399+
"Image(fig.to_image(format=\"png\", width=900, height=900))"
400400
]
401401
},
402402
{
@@ -495,7 +495,7 @@
495495
" 'y' : mpg.hwy \n",
496496
"})\n",
497497
"fig.add_trace(scatter)\n",
498-
"fig.show(renderer=\"png\")"
498+
"Image(fig.to_image(format=\"png\", width=900, height=900))"
499499
]
500500
},
501501
{
@@ -634,7 +634,7 @@
634634
"fig.add_trace(p2)\n",
635635
"fig.add_trace(p3)\n",
636636
"fig.add_trace(p4)\n",
637-
"fig.show(renderer=\"png\")"
637+
"Image(fig.to_image(format=\"png\", width=900, height=900))"
638638
]
639639
},
640640
{
@@ -764,7 +764,7 @@
764764
" },\n",
765765
" data=traces,\n",
766766
")\n",
767-
"fig.show(renderer=\"png\")"
767+
"Image(fig.to_image(format=\"png\", width=900, height=900))"
768768
]
769769
},
770770
{
@@ -867,7 +867,7 @@
867867
" },\n",
868868
" }\n",
869869
")\n",
870-
"fig.show(renderer=\"png\")"
870+
"Image(fig.to_image(format=\"png\", width=900, height=900))"
871871
]
872872
},
873873
{
@@ -950,7 +950,7 @@
950950
"outputs": [],
951951
"source": [
952952
"fig = figure_factory.create_facet_grid(df=mpg, x=\"displ\", y=\"cty\", facet_col=\"class\")\n",
953-
"fig.show(renderer=\"png\")"
953+
"Image(fig.to_image(format=\"png\", width=900, height=900))"
954954
]
955955
},
956956
{
@@ -1037,7 +1037,7 @@
10371037
" y = 'cty',\n",
10381038
" facet_col = 'cyl',\n",
10391039
" facet_row = 'drv')\n",
1040-
"fig.show(renderer=\"png\")"
1040+
"Image(fig.to_image(format=\"png\", width=900, height=900))"
10411041
]
10421042
},
10431043
{
@@ -1140,7 +1140,7 @@
11401140
" }\n",
11411141
" }\n",
11421142
"})\n",
1143-
"fig.show(renderer='png')\n"
1143+
"Image(fig.to_image(format=\"png\", width=900, height=900))"
11441144
]
11451145
},
11461146
{
@@ -1227,7 +1227,7 @@
12271227
" }, \n",
12281228
" }\n",
12291229
"})\n",
1230-
"fig.show(renderer=\"png\")"
1230+
"Image(fig.to_image(format=\"png\", width=900, height=900))"
12311231
]
12321232
},
12331233
{
@@ -1314,7 +1314,7 @@
13141314
" }, \n",
13151315
" }\n",
13161316
"})\n",
1317-
"fig.show(renderer=\"png\")"
1317+
"Image(fig.to_image(format=\"png\", width=900, height=900))"
13181318
]
13191319
},
13201320
{
@@ -1421,8 +1421,7 @@
14211421
" )\n",
14221422
"for d in fig['data']:\n",
14231423
" d.update({'fill' : 'tozeroy'})\n",
1424-
"\n",
1425-
"fig.show(renderer=\"png\")"
1424+
"Image(fig.to_image(format=\"png\", width=900, height=900))"
14261425
]
14271426
},
14281427
{
@@ -1492,7 +1491,7 @@
14921491
" 'y' : ts.value\n",
14931492
"})\n",
14941493
"fig.add_trace(scatter)\n",
1495-
"fig.show(renderer=\"png\")"
1494+
"Image(fig.to_image(format=\"png\", width=900, height=900))"
14961495
]
14971496
}
14981497
],

render.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def image_from_cell(cell):
6767
def source_from_cell(cell):
6868
source = "".join(cell['source']).strip()
6969
source = source.replace(";", "")
70-
source = source.replace("Image(export_png(p))", "") # remove bokeh render
70+
source = re.sub(r"^Image\(.*\)", "", source) # remove bokeh render
7171
if "%%R" in source:
7272
source = '\n'.join(source.split('\n')[1:])
7373
else:

0 commit comments

Comments
 (0)