Skip to content

Commit 32f6e7f

Browse files
committed
Merge remote-tracking branch 'origin/master' into kaleido
2 parents aee0e0d + f37fd3c commit 32f6e7f

File tree

5 files changed

+59
-15
lines changed

5 files changed

+59
-15
lines changed

Diff for: doc/python/multiple-axes.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jupyter:
2222
pygments_lexer: ipython3
2323
version: 3.7.2
2424
plotly:
25-
description: How to make a graph with multiple axes in python.
25+
description: How to make a graph with multiple axes (dual y-axis plots, plots with secondary axes) in python.
2626
display_as: file_settings
2727
language: python
2828
layout: base
@@ -225,4 +225,4 @@ fig.show()
225225
```
226226

227227
#### Reference
228-
All of the y-axis properties are found here: https://plotly.com/python/reference/#YAxis. For more information on creating subplots see the [Subplots in Python](/python/subplots/) section.
228+
All of the y-axis properties are found here: https://plotly.com/python/reference/#YAxis. For more information on creating subplots see the [Subplots in Python](/python/subplots/) section.

Diff for: doc/python/tick-formatting.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ fig.update_layout(yaxis_tickformat = '%')
9898
fig.show()
9999
```
100100

101-
#### Using Tickformat Atttribute - Date/Time
101+
#### Using Tickformat Attribute - Date/Time
102102

103103

104104
For more date/time formatting types, see: https://github.com/d3/d3-time-format/blob/master/README.md
@@ -194,4 +194,4 @@ fig.show()
194194
```
195195

196196
#### Reference
197-
See https://plotly.com/python/reference/#layout-xaxis for more information and chart attribute options!
197+
See https://plotly.com/python/reference/#layout-xaxis for more information and chart attribute options!

Diff for: doc/python/time-series.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ fig.show()
184184

185185
The `rangebreaks` attribute available on x- and y-axes of type `date` can be used to hide certain time-periods. In the example below, we show two plots: one in default mode to show gaps in the data, and one where we hide weekends and holidays to show an uninterrupted trading history. Note the smaller gaps between the grid lines for December 21 and January 4, where holidays were removed. Check out the reference for more options: https://plotly.com/python/reference/#layout-xaxis-rangebreaks
186186

187+
> Note: a known limitation of this feature is that it does not support `scattergl` traces. When using this feature on plots with more than a few hundred data points with `px.scatter` or `px.line` or `px.area`, you may need to pass in `render_mode="svg"` to ensure that the underlying trace type is `scatter` and not `scattergl`.
188+
187189
```python
188190
import plotly.express as px
189191
import pandas as pd
@@ -208,4 +210,4 @@ fig.update_xaxes(
208210
]
209211
)
210212
fig.show()
211-
```
213+
```

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ def make_docstring(fn, override_dict={}, append_dict={}):
538538
param_desc_list = param_doc[1:]
539539
param_desc = (
540540
tw.fill(" ".join(param_desc_list or ""))
541-
if param in docs
541+
if param in docs or param in override_dict
542542
else "(documentation missing from map)"
543543
)
544544

Diff for: packages/python/plotly/plotly/figure_factory/_dendrogram.py

+51-9
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,21 @@ def create_dendrogram(
2525
color_threshold=None,
2626
):
2727
"""
28-
Function that returns a dendrogram Plotly figure object.
28+
Function that returns a dendrogram Plotly figure object. This is a thin
29+
wrapper around scipy.cluster.hierarchy.dendrogram.
2930
3031
See also https://dash.plot.ly/dash-bio/clustergram.
3132
3233
:param (ndarray) X: Matrix of observations as array of arrays
3334
:param (str) orientation: 'top', 'right', 'bottom', or 'left'
3435
:param (list) labels: List of axis category labels(observation labels)
35-
:param (list) colorscale: Optional colorscale for dendrogram tree
36+
:param (list) colorscale: Optional colorscale for the dendrogram tree.
37+
Requires 8 colors to be specified, the 7th of
38+
which is ignored. With scipy>=1.5.0, the 2nd, 3rd
39+
and 6th are used twice as often as the others.
40+
Given a shorter list, the missing values are
41+
replaced with defaults and with a longer list the
42+
extra values are ignored.
3643
:param (function) distfun: Function to compute the pairwise distance from
3744
the observations
3845
:param (function) linkagefun: Function to compute the linkage matrix from
@@ -160,8 +167,8 @@ def __init__(
160167
if len(self.zero_vals) > len(yvals) + 1:
161168
# If the length of zero_vals is larger than the length of yvals,
162169
# it means that there are wrong vals because of the identicial samples.
163-
# Three and more identicial samples will make the yvals of spliting center into 0 and it will \
164-
# accidentally take it as leaves.
170+
# Three and more identicial samples will make the yvals of spliting
171+
# center into 0 and it will accidentally take it as leaves.
165172
l_border = int(min(self.zero_vals))
166173
r_border = int(max(self.zero_vals))
167174
correct_leaves_pos = range(
@@ -185,6 +192,9 @@ def get_color_dict(self, colorscale):
185192

186193
# These are the color codes returned for dendrograms
187194
# We're replacing them with nicer colors
195+
# This list is the colors that can be used by dendrogram, which were
196+
# determined as the combination of the default above_threshold_color and
197+
# the default color palette (see scipy/cluster/hierarchy.py)
188198
d = {
189199
"r": "red",
190200
"g": "green",
@@ -193,26 +203,58 @@ def get_color_dict(self, colorscale):
193203
"m": "magenta",
194204
"y": "yellow",
195205
"k": "black",
206+
# TODO: 'w' doesn't seem to be in the default color
207+
# palette in scipy/cluster/hierarchy.py
196208
"w": "white",
197209
}
198210
default_colors = OrderedDict(sorted(d.items(), key=lambda t: t[0]))
199211

200212
if colorscale is None:
201-
colorscale = [
213+
rgb_colorscale = [
202214
"rgb(0,116,217)", # blue
203215
"rgb(35,205,205)", # cyan
204216
"rgb(61,153,112)", # green
205217
"rgb(40,35,35)", # black
206218
"rgb(133,20,75)", # magenta
207219
"rgb(255,65,54)", # red
208220
"rgb(255,255,255)", # white
209-
"rgb(255,220,0)",
210-
] # yellow
221+
"rgb(255,220,0)", # yellow
222+
]
223+
else:
224+
rgb_colorscale = colorscale
211225

212226
for i in range(len(default_colors.keys())):
213227
k = list(default_colors.keys())[i] # PY3 won't index keys
214-
if i < len(colorscale):
215-
default_colors[k] = colorscale[i]
228+
if i < len(rgb_colorscale):
229+
default_colors[k] = rgb_colorscale[i]
230+
231+
# add support for cyclic format colors as introduced in scipy===1.5.0
232+
# before this, the colors were named 'r', 'b', 'y' etc., now they are
233+
# named 'C0', 'C1', etc. To keep the colors consistent regardless of the
234+
# scipy version, we try as much as possible to map the new colors to the
235+
# old colors
236+
# this mapping was found by inpecting scipy/cluster/hierarchy.py (see
237+
# comment above).
238+
new_old_color_map = [
239+
("C0", "b"),
240+
("C1", "g"),
241+
("C2", "r"),
242+
("C3", "c"),
243+
("C4", "m"),
244+
("C5", "y"),
245+
("C6", "k"),
246+
("C7", "g"),
247+
("C8", "r"),
248+
("C9", "c"),
249+
]
250+
for nc, oc in new_old_color_map:
251+
try:
252+
default_colors[nc] = default_colors[oc]
253+
except KeyError:
254+
# it could happen that the old color isn't found (if a custom
255+
# colorscale was specified), in this case we set it to an
256+
# arbitrary default.
257+
default_colors[n] = "rgb(0,116,217)"
216258

217259
return default_colors
218260

0 commit comments

Comments
 (0)