Skip to content

plotly_express integration #1613

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

Merged
merged 4 commits into from
Jun 14, 2019
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
6 changes: 2 additions & 4 deletions packages/python/plotly/plotly/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,15 @@
"""
from __future__ import absolute_import

# https://packaging.python.org/guides/packaging-namespace-packages/
# pkgutil-style-namespace-packages
__path__ = __import__('pkgutil').extend_path(__path__, __name__)

from plotly import (
graph_objs,
tools,
utils,
offline,
colors,
io,
data,
colors,
_docstring_gen
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,21 @@

from plotly import exceptions


# Built-in qualitative color sequences and sequential,
# diverging and cyclical color scales.
#
# Initially ported over from plotly_express
from . import ( # noqa: F401
qualitative,
sequential,
diverging,
cyclical,
cmocean,
colorbrewer,
carto,
)

DEFAULT_PLOTLY_COLORS = ['rgb(31, 119, 180)', 'rgb(255, 127, 14)',
'rgb(44, 160, 44)', 'rgb(214, 39, 40)',
'rgb(148, 103, 189)', 'rgb(140, 86, 75)',
Expand Down
37 changes: 37 additions & 0 deletions packages/python/plotly/plotly/colors/_swatches.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
def _swatches(module_names, module_contents):
"""
Returns:
A `Figure` object. This figure demonstrates the color scales and
sequences in this module, as stacked bar charts.
"""
import plotly.graph_objs as go

sequences = [
(k, v)
for k, v in module_contents.items()
if not (k.startswith("_") or k == "swatches")
]

return go.Figure(
data=[
go.Bar(
orientation="h",
y=[name] * len(colors),
x=[1] * len(colors),
customdata=list(range(len(colors))),
marker=dict(color=colors),
hovertemplate="%{y}[%{customdata}] = %{marker.color}<extra></extra>",
)
for name, colors in reversed(sequences)
],
layout=dict(
title=module_names,
barmode="stack",
barnorm="fraction",
template="plotly",
bargap=0.5,
showlegend=False,
xaxis=dict(range=[-0.02, 1.02], showticklabels=False, showgrid=False),
height=max(600, 40 * len(sequences)),
),
)
Loading