Skip to content

Commit ab194a4

Browse files
more title_text fixup
1 parent 2b535b9 commit ab194a4

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

Diff for: doc/python/imshow.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jupyter:
66
extension: .md
77
format_name: markdown
88
format_version: '1.2'
9-
jupytext_version: 1.3.1
9+
jupytext_version: 1.4.2
1010
kernelspec:
1111
display_name: Python 3
1212
language: python
@@ -20,7 +20,7 @@ jupyter:
2020
name: python
2121
nbconvert_exporter: python
2222
pygments_lexer: ipython3
23-
version: 3.6.8
23+
version: 3.7.7
2424
plotly:
2525
description: How to display image data in Python with Plotly.
2626
display_as: scientific

Diff for: packages/python/plotly/plotly/express/_core.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -1615,13 +1615,15 @@ def make_figure(args, constructor, trace_patch={}, layout_patch={}):
16151615
title_text=get_decorated_label(args, args[colorvar], colorvar)
16161616
),
16171617
)
1618-
for v in ["title", "height", "width"]:
1618+
for v in ["height", "width"]:
16191619
if args[v]:
1620-
layout_patch[v if v != "title" else "title_text"] = args[v]
1620+
layout_patch[v] = args[v]
16211621
layout_patch["legend"] = dict(tracegroupgap=0)
16221622
if trace_name_labels:
1623-
layout_patch["legend"]["title"] = dict(text=", ".join(trace_name_labels))
1624-
if "title" not in layout_patch and args["template"].layout.margin.t is None:
1623+
layout_patch["legend"]["title_text"] = ", ".join(trace_name_labels)
1624+
if args["title"]:
1625+
layout_patch["title_text"] = args["title"]
1626+
elif args["template"].layout.margin.t is None:
16251627
layout_patch["margin"] = {"t": 60}
16261628
if (
16271629
"size" in args
@@ -1651,7 +1653,7 @@ def make_figure(args, constructor, trace_patch={}, layout_patch={}):
16511653

16521654
# Add traces, layout and frames to figure
16531655
fig.add_traces(frame_list[0]["data"] if len(frame_list) > 0 else [])
1654-
fig.layout.update(layout_patch)
1656+
fig.update_layout(layout_patch)
16551657
if "template" in args and args["template"] is not None:
16561658
fig.update_layout(template=args["template"], overwrite=True)
16571659
fig.frames = frame_list if len(frames) > 1 else []

Diff for: packages/python/plotly/plotly/express/_imshow.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def imshow(
244244
cmax=range_color[1],
245245
)
246246
if labels["color"]:
247-
layout["coloraxis1"]["colorbar"] = dict(title=labels["color"])
247+
layout["coloraxis1"]["colorbar"] = dict(title_text=labels["color"])
248248

249249
# For 2D+RGB data, use Image trace
250250
elif img.ndim == 3 and img.shape[-1] in [3, 4]:
@@ -262,10 +262,12 @@ def imshow(
262262
)
263263

264264
layout_patch = dict()
265-
for attr_name in ["title", "height", "width"]:
265+
for attr_name in ["height", "width"]:
266266
if args[attr_name]:
267267
layout_patch[attr_name] = args[attr_name]
268-
if "title" not in layout_patch and args["template"].layout.margin.t is None:
268+
if args["title"]:
269+
layout_patch["title_text"] = args["title"]
270+
elif args["template"].layout.margin.t is None:
269271
layout_patch["margin"] = {"t": 60}
270272
fig = go.Figure(data=trace, layout=layout)
271273
fig.update_layout(layout_patch)

0 commit comments

Comments
 (0)