Skip to content

Commit c5842bc

Browse files
docstrings and tests
1 parent f367c72 commit c5842bc

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@
283283
],
284284
title=["str", "The figure title."],
285285
template=[
286-
"str or Plotly.py template object",
286+
"or dict or plotly.graph_objects.layout.Template instance",
287287
"The figure template name or definition.",
288288
],
289289
width=["int (default `None`)", "The figure width in pixels."],

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

+15-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ def imshow(
9797
9898
color_continuous_scale : str or list of str
9999
colormap used to map scalar data to colors (for a 2D image). This parameter is
100-
not used for RGB or RGBA images.
100+
not used for RGB or RGBA images. If a string is provided, it should be the name
101+
of a known color scale, and if a list is provided, it should be a list of CSS-
102+
compatible colors.
101103
102104
color_continuous_midpoint : number
103105
If set, computes the bounds of the continuous color scale to have the desired
@@ -107,6 +109,18 @@ def imshow(
107109
If provided, overrides auto-scaling on the continuous color scale, including
108110
overriding `color_continuous_midpoint`.
109111
112+
title : str
113+
The figure title.
114+
115+
template : str or dict or plotly.graph_objects.layout.Template instance
116+
The figure template name or definition.
117+
118+
width : number
119+
The figure width in pixels.
120+
121+
height: number
122+
The figure height in pixels, defaults to 600.
123+
110124
Returns
111125
-------
112126
fig : graph_objects.Figure containing the displayed image

Diff for: packages/python/plotly/plotly/tests/test_core/test_px/test_imshow.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ def test_origin():
5050

5151
def test_colorscale():
5252
fig = px.imshow(img_gray)
53-
assert fig.data[0].colorscale[0] == (0.0, "rgb(0, 0, 0)")
54-
fig = px.imshow(img_gray, colorscale="Viridis")
55-
assert fig.data[0].colorscale[0] == (0.0, "#440154")
53+
plasma_first_color = px.colors.sequential.Plasma[0]
54+
assert fig.layout.coloraxis1.colorscale[0] == (0.0, plasma_first_color)
55+
fig = px.imshow(img_gray, color_continuous_scale="Viridis")
56+
assert fig.layout.coloraxis1.colorscale[0] == (0.0, "#440154")
5657

5758

5859
def test_wrong_dimensions():

0 commit comments

Comments
 (0)