Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

title.text everywhere in PX #2402

Merged
merged 2 commits into from
Apr 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/python/imshow.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.2'
jupytext_version: 1.3.1
jupytext_version: 1.4.2
kernelspec:
display_name: Python 3
language: python
Expand All @@ -20,7 +20,7 @@ jupyter:
name: python
nbconvert_exporter: python
pygments_lexer: ipython3
version: 3.6.8
version: 3.7.7
plotly:
description: How to display image data in Python with Plotly.
display_as: scientific
Expand Down
26 changes: 15 additions & 11 deletions packages/python/plotly/plotly/express/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,9 +551,9 @@ def configure_cartesian_axes(args, fig, orders):
def configure_ternary_axes(args, fig, orders):
fig.update_layout(
ternary=dict(
aaxis=dict(title=get_label(args, args["a"])),
baxis=dict(title=get_label(args, args["b"])),
caxis=dict(title=get_label(args, args["c"])),
aaxis=dict(title_text=get_label(args, args["a"])),
baxis=dict(title_text=get_label(args, args["b"])),
caxis=dict(title_text=get_label(args, args["c"])),
)
)

Expand Down Expand Up @@ -588,9 +588,9 @@ def configure_polar_axes(args, fig, orders):
def configure_3d_axes(args, fig, orders):
layout = dict(
scene=dict(
xaxis=dict(title=get_label(args, args["x"])),
yaxis=dict(title=get_label(args, args["y"])),
zaxis=dict(title=get_label(args, args["z"])),
xaxis=dict(title_text=get_label(args, args["x"])),
yaxis=dict(title_text=get_label(args, args["y"])),
zaxis=dict(title_text=get_label(args, args["z"])),
)
)

Expand Down Expand Up @@ -1611,15 +1611,19 @@ def make_figure(args, constructor, trace_patch={}, layout_patch={}):
cmid=args["color_continuous_midpoint"],
cmin=range_color[0],
cmax=range_color[1],
colorbar=dict(title=get_decorated_label(args, args[colorvar], colorvar)),
colorbar=dict(
title_text=get_decorated_label(args, args[colorvar], colorvar)
),
)
for v in ["title", "height", "width"]:
for v in ["height", "width"]:
if args[v]:
layout_patch[v] = args[v]
layout_patch["legend"] = dict(tracegroupgap=0)
if trace_name_labels:
layout_patch["legend"]["title"] = ", ".join(trace_name_labels)
if "title" not in layout_patch and args["template"].layout.margin.t is None:
layout_patch["legend"]["title_text"] = ", ".join(trace_name_labels)
if args["title"]:
layout_patch["title_text"] = args["title"]
elif args["template"].layout.margin.t is None:
layout_patch["margin"] = {"t": 60}
if (
"size" in args
Expand Down Expand Up @@ -1649,7 +1653,7 @@ def make_figure(args, constructor, trace_patch={}, layout_patch={}):

# Add traces, layout and frames to figure
fig.add_traces(frame_list[0]["data"] if len(frame_list) > 0 else [])
fig.layout.update(layout_patch)
fig.update_layout(layout_patch)
if "template" in args and args["template"] is not None:
fig.update_layout(template=args["template"], overwrite=True)
fig.frames = frame_list if len(frames) > 1 else []
Expand Down
8 changes: 5 additions & 3 deletions packages/python/plotly/plotly/express/_imshow.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def imshow(
cmax=range_color[1],
)
if labels["color"]:
layout["coloraxis1"]["colorbar"] = dict(title=labels["color"])
layout["coloraxis1"]["colorbar"] = dict(title_text=labels["color"])

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

layout_patch = dict()
for attr_name in ["title", "height", "width"]:
for attr_name in ["height", "width"]:
if args[attr_name]:
layout_patch[attr_name] = args[attr_name]
if "title" not in layout_patch and args["template"].layout.margin.t is None:
if args["title"]:
layout_patch["title_text"] = args["title"]
elif args["template"].layout.margin.t is None:
layout_patch["margin"] = {"t": 60}
fig = go.Figure(data=trace, layout=layout)
fig.update_layout(layout_patch)
Expand Down