Skip to content

[BUG] create_facet figure factory when color_names are numbers #1919

Closed
@emmanuelle

Description

@emmanuelle

Was caught by this docstring example

   >>> import plotly.figure_factory as ff
    >>> import pandas as pd
    >>> tips = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/tips.csv')

    >>> fig = ff.create_facet_grid(
    ...     tips,
    ...     x='total_bill',
    ...     y='tip',
    ...     facet_row='sex',
    ...     facet_col='smoker',
    ...     color_name='size',
    ...     colormap='Viridis',
    ... )
    >>> fig.show()

The error is

Traceback (most recent call last):
  File "<ipython-input-45-2e217ba09405>", line 10, in <module>
    color_is_cat=True,
  File "/home/emma/code/plotly.py/packages/python/plotly/plotly/figure_factory/_facet_grid.py", line 952, in create_facet_grid
    kwargs_marker,
  File "/home/emma/code/plotly.py/packages/python/plotly/plotly/figure_factory/_facet_grid.py", line 257, in _facet_grid_color_categorical
    trace, j + 1 if facet_row else 1, 1 if facet_row else j + 1
  File "/home/emma/code/plotly.py/packages/python/plotly/plotly/basedatatypes.py", line 1789, in append_trace
  File "/home/emma/code/plotly.py/packages/python/plotly/plotly/basedatatypes.py", line 1615, in add_trace
    cols=[col] if col is not None else None,
  File "/home/emma/code/plotly.py/packages/python/plotly/plotly/basedatatypes.py", line 1676, in add_traces
    # Validate traces
  File "/home/emma/code/plotly.py/packages/python/plotly/_plotly_utils/basevalidators.py", line 2645, in validate_coerce
    skip_invalid=skip_invalid, **v_copy
  File "/home/emma/code/plotly.py/packages/python/plotly/plotly/graph_objs/__init__.py", line 37591, in __init__
    self["name"] = name if name is not None else _v
  File "/home/emma/code/plotly.py/packages/python/plotly/plotly/basedatatypes.py", line 3479, in __setitem__
    else:
  File "/home/emma/code/plotly.py/packages/python/plotly/plotly/basedatatypes.py", line 3766, in _set_prop
    else:
  File "/home/emma/code/plotly.py/packages/python/plotly/plotly/basedatatypes.py", line 3761, in _set_prop
    try:
  File "/home/emma/code/plotly.py/packages/python/plotly/_plotly_utils/basevalidators.py", line 1080, in validate_coerce
    self.raise_invalid_val(v)
  File "/home/emma/code/plotly.py/packages/python/plotly/_plotly_utils/basevalidators.py", line 283, in raise_invalid_val
    valid_clr_desc=self.description(),
ValueError: 
    Invalid value of type 'numpy.int64' received for the 'name' property of scatter
        Received value: 6

    The 'name' property is a string and must be specified as:
      - A string
      - A number that will be converted to a string

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