What this PR does / why we need it:
Fixes bug with categorical_order_by and numpy arrays / pandas series
Which issue(s) this PR fixes
Fixes #74
Special notes for your reviewer:
While writing the tests I discovered some weirdness in the chart data:
the data for bar charts (and all other plots using PlotMixedTypeXY._construct_source) is in order of the specified ordering
the scatter data is in the initial order (i.e. not ordered)
Nevertheless, in the chart, the data is displayed correctly, because not the order of the chart data defines the category order but the order of the factors of bokeh.plotting.figure.x_range (vertical) or bokeh.plotting.figure.y_range (horizontal).
And that is set by PlotMixedTypeXY._set_categorical_axis_default_factors.
What happens is that:
for plots using PlotMixedTypeXY._construct_source, the data gets sorted and then the x_range is set accordingly
for a scatter plot, factors are sorted and x_range.factors is set but the actual data does not get sorted
So it seems like sorting the actual data (like in _construct_source) is unnecessary as bokeh does not consider the order of the data itself but instead maps the observations to the corresponding factors in the x_range.
I think this can be addressed in a separate issue.
Release note:
Support ordering categories using array_like (numpy array, pandas series)
What this PR does / why we need it: Fixes bug with categorical_order_by and numpy arrays / pandas series Which issue(s) this PR fixes
Fixes #74
Special notes for your reviewer: While writing the tests I discovered some weirdness in the chart data:
PlotMixedTypeXY._construct_source
) is in order of the specified orderingNevertheless, in the chart, the data is displayed correctly, because not the order of the chart data defines the category order but the order of the factors of
bokeh.plotting.figure.x_range
(vertical) orbokeh.plotting.figure.y_range
(horizontal). And that is set byPlotMixedTypeXY._set_categorical_axis_default_factors
.What happens is that:
PlotMixedTypeXY._construct_source
, the data gets sorted and then thex_range
is set accordinglyx_range.factors
is set but the actual data does not get sortedSo it seems like sorting the actual data (like in
_construct_source
) is unnecessary as bokeh does not consider the order of the data itself but instead maps the observations to the corresponding factors in thex_range
.I think this can be addressed in a separate issue.
Release note: