Nested x-axis categoricals from pandas dataframe without groupby aggregation

Hi, thanks for responding. I’m afraid I don’t follow.

Here is the error I get if I use a dataframe without a groupby.

from bokeh.io import output_file, show
from bokeh.models import ColumnDataSource, FactorRange
from bokeh.plotting import figure

reset_output()
output_notebook()

# make list of tuples to use as factors
factors = tidy_df.set_index(["fruit", "year"]).index.tolist()
print(factors)

# attempt to plot without using pd.groupby()
source = ColumnDataSource(tidy_df)

# make figure
p = figure(plot_height=400,
           plot_width=400,
           x_range=FactorRange(*factors), 
           title="Fruit by Year",
)

# add glyphs? renderers? dunno?
p.circle(x=factors, 
         y="value",
         width=5, 
         source=source,
        )

# show figure
show(p)

Output:

 [('Apples', '2015'), ('Pears', '2015'), ('Apples', '2016'), ('Pears', '2016')]`
    ---------------------------------------------------------------------------
    RuntimeError                              Traceback (most recent call last)
    <ipython-input-554-125b597928c2> in <module>
         24          y="value",
         25          width=5,
    ---> 26          source=source,
         27         )
         28 

~\AppData\Local\Continuum\anaconda3\envs\py37\lib\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)

~\AppData\Local\Continuum\anaconda3\envs\py37\lib\site-packages\bokeh\plotting\_renderer.py in create_renderer(glyphclass, plot, **kwargs)
     92     incompatible_literal_spec_values += _process_sequence_literals(glyphclass, glyph_visuals, source, is_user_source)
     93     if incompatible_literal_spec_values:
---> 94         raise RuntimeError(_GLYPH_SOURCE_MSG % nice_join(incompatible_literal_spec_values, conjuction="and"))
     95 
     96     # handle the nonselection glyph, we always set one

RuntimeError: 

Expected x to reference fields in the supplied data source.

When a 'source' argument is passed to a glyph method, values that are sequences
(like lists or arrays) must come from references to data columns in the source.

For instance, as an example:

    source = ColumnDataSource(data=dict(x=a_list, y=an_array))

    p.circle(x='x', y='y', source=source, ...) # pass column names and a source

Alternatively, *all* data sequences may be provided as literals as long as a
source is *not* provided:

    p.circle(x=a_list, y=an_array, ...)  # pass actual sequences and no source