Skip to content

Conversation

@Trevor16gordon
Copy link

Fixes legend error:
This change belongs with this commit but was likely missed.
3af29e8#diff-17b8994a0f281801a29c52fc0dc9491168ac64e795936bc9d6aa663f7892311c

Problem reproduced when plotting with grouping and colors:

import chartify
import pandas as pd
df = pd.DataFrame.from_dict({"data":[1,1,2,2,3,3], "group":["a","a","a","b","b","b"]})
ch = chartify.Chart(x_axis_type='categorical')
ch.plot.scatter(
data_frame=df,
categorical_columns="group",
numeric_column="data",
color_column="group",
)
ch.show()
Error

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-1-eae93029a0e8> in <module>
      7 categorical_columns="group",
      8 numeric_column="data",
----> 9 color_column="group",
     10 )
     11 ch.show()

~/.virtualenvs/murph_commonality/lib/python3.7/site-packages/chartify-3.0.3-py3.7.egg/chartify/_core/plot.py in scatter(self, data_frame, categorical_columns, numeric_column, size_column, color_column, color_order, categorical_order_by, categorical_order_ascending, alpha, marker)
   2050                 source=source,
   2051                 marker=marker,
-> 2052                 alpha=alpha
   2053                 )
   2054 

~/.virtualenvs/murph_commonality/lib/python3.7/site-packages/chartify-3.0.3-py3.7.egg/chartify/_core/plot.py in _plot_with_legend(method, **kwargs)
    126 
    127         if legend_label is not None:
--> 128             return method(**kwargs, legend_label=legend_label)
    129         elif legend_group is not None:
    130             return method(**kwargs, legend_group=legend_group)

~/.virtualenvs/murph_commonality/lib/python3.7/site-packages/bokeh/plotting/figure.py in scatter(self, *args, **kwargs)
   1088             return self.circle(*args, **kwargs)
   1089         else:
-> 1090             return self._scatter(*args, marker=marker_type, **kwargs)
   1091 
   1092     def hexbin(self, x, y, size, orientation="pointytop", palette="Viridis256", line_color=None, fill_color=None, aspect_scale=1, **kwargs):

~/.virtualenvs/murph_commonality/lib/python3.7/site-packages/bokeh/plotting/_decorators.py in wrapped(self, *args, **kwargs)
     52             for arg, param in zip(args, sigparams[1:]):
     53                 kwargs[param.name] = arg
---> 54             return create_renderer(glyphclass, self, **kwargs)
     55 
     56         wrapped.__signature__ = Signature(parameters=sigparams)

~/.virtualenvs/murph_commonality/lib/python3.7/site-packages/bokeh/plotting/_renderer.py in create_renderer(glyphclass, plot, **kwargs)
    129         # if it creates a new `LegendItem`, the referenced
    130         # renderer must already be present.
--> 131         update_legend(plot, legend_kwarg, glyph_renderer)
    132 
    133     return glyph_renderer

~/.virtualenvs/murph_commonality/lib/python3.7/site-packages/bokeh/plotting/_legends.py in update_legend(plot, legend_kwarg, glyph_renderer)
     54     kwarg, value = list(legend_kwarg.items())[0]
     55 
---> 56     _LEGEND_KWARG_HANDLERS[kwarg](value, legend, glyph_renderer)
     57 
     58 #-----------------------------------------------------------------------------

~/.virtualenvs/murph_commonality/lib/python3.7/site-packages/bokeh/plotting/_legends.py in _handle_legend_label(label, legend, glyph_renderer)
    129 def _handle_legend_label(label, legend, glyph_renderer):
    130     if not isinstance(label, str):
--> 131         raise ValueError("legend_label value must be a string")
    132     label = value(label)
    133     item = _find_legend_item(label, legend)

ValueError: legend_label value must be a string

Special notes for your reviewer:

Release note:


According to this Bokeh release 1.4.0 when using explicit legend_label, you can no longer pass legend label as a dictionary with "value" key.
https://docs.bokeh.org/en/latest/docs/releases.html#release-1-4-0

@iampelle iampelle changed the base branch from master to Release-3.0.4 October 17, 2022 20:19
iampelle added a commit that referenced this pull request Oct 17, 2022
@iampelle
Copy link
Contributor

Fix, together with test case added in bc26739

@iampelle iampelle closed this Oct 17, 2022
iampelle added a commit that referenced this pull request Oct 17, 2022
iampelle added a commit that referenced this pull request Oct 18, 2022
This update is a maintanaince release with no new features and mainly behind the scenes updates:
* Update github actions
* Limit versions of bokeh, Jinja, and importlib-metadata to fix build error. This is only necessary for python 3.6 it seems.
* Updated required versions of pytest and coverage
* Update setup.py (#135)
* Update options.py (#133)
* Change ChromeDriver link to avoid deprecated site (#134)
* Added test case and fix from [PR #127](#127)
* Eliminate a number of deprecation warnings
* Add publish to PyPi workflow

Co-authored-by: Anurag Kumar <mailanu98@gmail.com>
Co-authored-by: Moad Akhraz <77294440+mdakh404@users.noreply.github.com>
Co-authored-by: Damian <54457902+dxbednarczyk@users.noreply.github.com>
Co-authored-by: Damian <54457902+dbednar230@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

2 participants