Skip to content

univariate_densities is broken with plotly 7: create_distplot was removed #99

Description

@hmgaudecker

Summary

univariate_densities calls plotly.figure_factory.create_distplot, which was removed
in plotly 7.0.0. The function raises AttributeError with any plotly 7 installation,
and pyproject.toml allows plotly 7 to be installed.

Reproduction

plotly 7.0.0
has create_distplot: False
import plotly.figure_factory as ff

ff.create_distplot(...)
# AttributeError: module 'plotly.figure_factory' has no attribute 'create_distplot'

Call site: src/skillmodels/common/visualize_factor_distributions.py:255

fig = ff.create_distplot(hist_data, **distplot_kwargs)

create_distplot is the only figure_factory use in the package:

src/skillmodels/common/visualize_factor_distributions.py:11:import plotly.figure_factory as ff
src/skillmodels/common/visualize_factor_distributions.py:209:            ff.create_distplot().
src/skillmodels/common/visualize_factor_distributions.py:255:            fig = ff.create_distplot(hist_data, **distplot_kwargs)

Background

plotly 7.0.0 (released 2026-08-25) removed a group of long-deprecated figure factories,
create_distplot among them, along with create_2d_density,
create_annotated_heatmap, create_violin, create_scatterplotmatrix and others. See
Changes in version 7. The documented
replacement for create_distplot is px.histogram() with the marginal argument.

Impact

univariate_densities is unusable on plotly 7. Anything calling it fails at runtime, so
combine_distribution_plots is affected wherever it is fed univariate densities.

This is particularly awkward for projects running inside secure environments, where the
conda environment is built once by an administrator and cannot be changed by the
researcher. If the environment happened to resolve plotly 7, the function cannot be used
at all and there is no local remedy.

Suggested fix

Two parts, the first of which is worth doing regardless:

  1. Constrain the dependency so an incompatible plotly cannot be installed silently —
    plotly>=6.6,<7 until the call is migrated.
  2. Migrate off the removed factory. px.histogram(..., marginal=...) is the
    documented path. Note that create_distplot's show_hist / show_curve /
    show_rug switches do not map one-to-one, so the replacement is an API decision
    rather than a drop-in substitution — in particular whether the KDE curve stays
    available on its own, without a histogram.

A regression test that imports and calls univariate_densities would have caught this;
there does not appear to be one exercising the plotting path against the installed
plotly.

Related

The rug option is worth a thought while this is being reworked: show_rug=True places
one marker per observation in the figure, which is individual-level data. Projects
working under statistical disclosure rules cannot release such a figure. Not a bug, but
relevant to whichever replacement API is chosen, and related to #98.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions