@@ -101,6 +101,7 @@ def ridgeplot(
101101 densities : Densities | ShallowDensities | None = None ,
102102 trace_type : TraceTypesArray | ShallowTraceTypesArray | TraceType | None = None ,
103103 labels : LabelsArray | ShallowLabelsArray | None = None ,
104+ row_labels : Collection [str ] | None | Literal [False ] = None ,
104105 # KDE parameters
105106 kernel : str = "gau" ,
106107 bandwidth : KDEBandwidth = "normal_reference" ,
@@ -117,11 +118,11 @@ def ridgeplot(
117118 line_color : Color | Literal ["fill-color" ] = "black" ,
118119 line_width : float | None = None ,
119120 spacing : float = 0.5 ,
120- show_yticklabels : bool = True ,
121121 xpad : float = 0.05 ,
122122 # Deprecated parameters
123123 coloralpha : float | None | MissingType = MISSING ,
124124 linewidth : float | MissingType = MISSING ,
125+ show_yticklabels : bool | MissingType = MISSING ,
125126) -> go .Figure :
126127 r"""Return an interactive ridgeline (Plotly) |~go.Figure|.
127128
@@ -196,10 +197,24 @@ def ridgeplot(
196197 .. versionadded:: 0.3.0
197198
198199 labels : LabelsArray or ShallowLabelsArray or None
199- A list of string labels for each trace. If not specified (default), the
200- labels will be automatically generated as ``"Trace {n}"``, where ``n``
201- is the trace's index. If instead a list of labels is specified, it
202- should have the same shape as the samples array.
200+ A collection of string labels for each trace. If not specified
201+ (default), the labels will be automatically generated as
202+ ``"Trace {i}"``, where ``i`` is the trace's index. If instead a
203+ collection of labels is specified, it should have the same shape as the
204+ samples array.
205+
206+ row_labels : Collection[str] or None or False
207+ A collection of string labels for each row in the ridgeline plot. If
208+ specified, the length of this collection should match the number of rows
209+ in the plot (i.e., the :math:`R` dimension in the :paramref:`.samples`
210+ or :paramref:`.densities` parameter). If not specified (default), the
211+ row labels displayed on the y-axis will be automatically generated based
212+ on the :paramref:`.labels` argument. If set to ``False``, the row
213+ labels won't be displayed at all.
214+
215+ .. versionadded:: 0.4.0
216+ Added support for custom row labels, and replaced the deprecated
217+ :paramref:`.show_yticklabels` parameter.
203218
204219 kernel : str
205220 The Kernel to be used during Kernel Density Estimation. The default is
@@ -226,14 +241,14 @@ def ridgeplot(
226241 ``"scott"`` bandwidth for gaussian kernels. See `bandwidths.py`_.
227242 - If a float is given, its value is used as the bandwidth.
228243 - If a callable is given, it's return value is used. The callable
229- should take exactly two parameters , i.e., ``fn(x, kern)``, and return
244+ should take exactly two arguments , i.e., ``fn(x, kern)``, and return
230245 a float, where:
231246
232247 - ``x``: the clipped input data
233248 - ``kern``: the kernel instance used
234249
235250 kde_points : KDEPoints
236- This argument controls the points at which KDE is computed. If an
251+ This parameter controls the points at which KDE is computed. If an
237252 ``int`` value is passed (default=500), the densities will be evaluated
238253 at ``kde_points`` evenly spaced points between the min and max of each
239254 set of samples. Optionally, you can also pass a custom 1D numerical
@@ -278,7 +293,7 @@ def ridgeplot(
278293 template.
279294
280295 colormode : "fillgradient" or SolidColormode
281- This argument controls the logic used for the coloring of each
296+ This parameter controls the logic used for the coloring of each
282297 ridgeline trace.
283298
284299 The ``"fillgradient"`` mode (default) will fill each trace with a
@@ -323,13 +338,13 @@ def ridgeplot(
323338 ``"fillgradient"``.
324339
325340 opacity : float or None
326- If None (default), this argument will be ignored and the transparency
341+ If None (default), this parameter will be ignored and the transparency
327342 values of the specified color-scale will remain untouched. Otherwise,
328343 if a float value is passed, it will be used to overwrite the
329344 opacity/transparency of the color-scale's colors.
330345
331346 .. versionadded:: 0.2.0
332- Replaces the deprecated :paramref:`.coloralpha` argument .
347+ Replaces the deprecated :paramref:`.coloralpha` parameter .
333348
334349 line_color : Color or "fill-color"
335350 The color of the traces' lines. Any valid CSS color is allowed
@@ -347,20 +362,14 @@ def ridgeplot(
347362 of 0.5 px.
348363
349364 .. versionadded:: 0.2.0
350- Replaces the deprecated :paramref:`.linewidth` argument .
365+ Replaces the deprecated :paramref:`.linewidth` parameter .
351366
352367 .. versionchanged:: 0.2.0
353368 The default value changed from 1 to 1.5
354369
355370 spacing : float
356371 The vertical spacing between density traces, which is defined in units
357- of the highest distribution (i.e. the maximum y-value).
358-
359- show_yticklabels : bool
360- Whether to show the tick labels on the y-axis. The default is True.
361-
362- .. versionadded:: 0.1.21
363- Replaces the deprecated :paramref:`.show_annotations` argument.
372+ of the highest distribution (i.e., the maximum y-value).
364373
365374 xpad : float
366375 Specifies the extra padding to use on the x-axis. It is defined in
@@ -377,6 +386,11 @@ def ridgeplot(
377386 .. deprecated:: 0.2.0
378387 Use :paramref:`.line_width` instead.
379388
389+ show_yticklabels : bool
390+
391+ .. deprecated:: 0.4.0
392+ Use :paramref:`.row_labels` instead.
393+
380394 Returns
381395 -------
382396 :class:`plotly.graph_objects.Figure`
@@ -437,6 +451,21 @@ def ridgeplot(
437451 )
438452 line_width = linewidth
439453
454+ if show_yticklabels is not MISSING :
455+ if row_labels is not None :
456+ raise ValueError (
457+ "You may not specify both the 'show_yticklabels' and 'row_labels' arguments! "
458+ "HINT: Use the new 'row_labels' argument instead of the deprecated "
459+ "'show_yticklabels'."
460+ )
461+ warnings .warn (
462+ "The 'show_yticklabels' argument has been deprecated in favor of 'row_labels'. "
463+ "Support for the deprecated argument will be removed in a future version." ,
464+ DeprecationWarning ,
465+ stacklevel = 2 ,
466+ )
467+ row_labels = False if not show_yticklabels else None
468+
440469 if colorscale == "default" :
441470 warnings .warn (
442471 "colorscale='default' is deprecated and support for it will be removed in a future "
@@ -454,13 +483,13 @@ def ridgeplot(
454483 densities = densities ,
455484 trace_labels = labels ,
456485 trace_types = trace_type ,
486+ row_labels = row_labels ,
457487 colorscale = colorscale ,
458488 opacity = opacity ,
459489 colormode = colormode ,
460490 line_color = line_color ,
461491 line_width = line_width ,
462492 spacing = spacing ,
463- show_yticklabels = show_yticklabels ,
464493 xpad = xpad ,
465494 )
466495 return fig
0 commit comments