Skip to content
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

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

Closed
emmanuelle opened this issue Nov 22, 2019 · 3 comments
Closed

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

emmanuelle opened this issue Nov 22, 2019 · 3 comments

Comments

@emmanuelle
Copy link
Contributor

emmanuelle commented Nov 22, 2019

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
@emmanuelle
Copy link
Contributor Author

Let's see if we want to fix this or if create_facet_grid is old and should be replaced by px.

@nicolaskruchten
Copy link
Contributor

this should be marked as "deprecated" in the docstring I think :)

@emmanuelle
Copy link
Contributor Author

Closing since we gradually deprecate the function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants