Inability to plot patches with factors on the x-axis

Hello there,

I am trying to modify this example (http://bokeh.pydata.org/en/latest/docs/gallery/brewer.html), so as to have timedates or strings on the x-axis instead of numeric values. I have tried the modifications recommended at SO (https://stackoverflow.com/questions/42426410/bokeh-patches-plot-with-dates-as-x-axis-shifts-the-ticks-one-to-the-right?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa), making the needed changes and so the code that I’ve been trying to implement is:

from bokeh.plotting import figure, show, output_file

from bokeh.palettes import brewer

from bokeh.io import show

from bokeh.models import FactorRange

N = 20

categories = [‘y’ + str(x) for x in range(10)]

data = {}

data[‘x’] = np.arange(1,N+1)

for cat in categories:

data[cat] = np.random.randint(10, 100, size=N)

df = pd.DataFrame(data)

df = df.set_index([‘x’])

def stacked(df, categories):

areas = dict()

last = np.zeros(len(df[categories[0]]))

for cat in categories:

next = last + df[cat]

areas[cat] = np.hstack((last[::-1], next))

last = next

return areas

areas = stacked(df, categories)

colors = brewer[“Spectral”][len(areas)]

x2 = np.hstack((data[‘x’][::-1], data[‘x’]))

timesteps = [str(x.date()) for x in pd.date_range(‘1950-01-01’, ‘1951-08-01’, freq=‘MS’)]

p = figure(x_range=FactorRange(factors=timesteps), y_range=(0, 800))

p.grid.minor_grid_line_color = ‘#eeeeee

p.patches([x2] * len(areas), [areas[cat] for cat in categories],

color=colors, alpha=0.8, line_color=None)

p.xaxis.major_label_orientation = np.pi/4

show§

However, this is not working anymore.

Does anyone have any idea on some possible fixes?

Thanks

This was a bug that was recently fixed on master:

  https://github.com/bokeh/bokeh/issues/7462

You can try dev build immediately, or wait for the next release.

Thanks,

Bryan

···

On Apr 18, 2018, at 01:00, SinniK Al <[email protected]> wrote:

Hello there,

I am trying to modify this example (http://bokeh.pydata.org/en/latest/docs/gallery/brewer.html), so as to have timedates or strings on the x-axis instead of numeric values. I have tried the modifications recommended at SO (https://stackoverflow.com/questions/42426410/bokeh-patches-plot-with-dates-as-x-axis-shifts-the-ticks-one-to-the-right?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa), making the needed changes and so the code that I've been trying to implement is:

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

N = 20
categories = ['y' + str(x) for x in range(10)]
data = {}
data['x'] = np.arange(1,N+1)
for cat in categories:
    data[cat] = np.random.randint(10, 100, size=N)

df = pd.DataFrame(data)
df = df.set_index(['x'])

def stacked(df, categories):
    areas = dict()
    last = np.zeros(len(df[categories[0]]))
    for cat in categories:
        next = last + df[cat]
        areas[cat] = np.hstack((last[::-1], next))
        last = next
    return areas

areas = stacked(df, categories)

colors = brewer["Spectral"][len(areas)]

x2 = np.hstack((data['x'][::-1], data['x']))

timesteps = [str(x.date()) for x in pd.date_range('1950-01-01', '1951-08-01', freq='MS')]
p = figure(x_range=FactorRange(factors=timesteps), y_range=(0, 800))

p.grid.minor_grid_line_color = '#eeeeee'

p.patches([x2] * len(areas), [areas[cat] for cat in categories],
          color=colors, alpha=0.8, line_color=None)
p.xaxis.major_label_orientation = np.pi/4
show(p)

However, this is not working anymore.
Does anyone have any idea on some possible fixes?

Thanks

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/5769d4ab-91dd-401e-843a-4975574df34f%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Thank you Bryan.

How could I try dev build?

···

2018-04-19 0:13 GMT+03:00 Bryan Van de ven [email protected]:

This was a bug that was recently fixed on master:

    [https://github.com/bokeh/bokeh/issues/7462](https://github.com/bokeh/bokeh/issues/7462)

You can try dev build immediately, or wait for the next release.

Thanks,

Bryan

On Apr 18, 2018, at 01:00, SinniK Al [email protected] wrote:

Hello there,

I am trying to modify this example (http://bokeh.pydata.org/en/latest/docs/gallery/brewer.html), so as to have timedates or strings on the x-axis instead of numeric values. I have tried the modifications recommended at SO (https://stackoverflow.com/questions/42426410/bokeh-patches-plot-with-dates-as-x-axis-shifts-the-ticks-one-to-the-right?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa), making the needed changes and so the code that I’ve been trying to implement is:

from bokeh.plotting import figure, show, output_file

from bokeh.palettes import brewer

from bokeh.io import show

from bokeh.models import FactorRange

N = 20

categories = [‘y’ + str(x) for x in range(10)]

data = {}

data[‘x’] = np.arange(1,N+1)

for cat in categories:

data[cat] = np.random.randint(10, 100, size=N)

df = pd.DataFrame(data)

df = df.set_index([‘x’])

def stacked(df, categories):

areas = dict()
last = np.zeros(len(df[categories[0]]))
for cat in categories:
    next = last + df[cat]
    areas[cat] = np.hstack((last[::-1], next))
    last = next
return areas

areas = stacked(df, categories)

colors = brewer[“Spectral”][len(areas)]

x2 = np.hstack((data[‘x’][::-1], data[‘x’]))

timesteps = [str(x.date()) for x in pd.date_range(‘1950-01-01’, ‘1951-08-01’, freq=‘MS’)]

p = figure(x_range=FactorRange(factors=timesteps), y_range=(0, 800))

p.grid.minor_grid_line_color = ‘#eeeeee

p.patches([x2] * len(areas), [areas[cat] for cat in categories],

      color=colors, alpha=0.8, line_color=None)

p.xaxis.major_label_orientation = np.pi/4

show§

However, this is not working anymore.

Does anyone have any idea on some possible fixes?

Thanks

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/5769d4ab-91dd-401e-843a-4975574df34f%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/808B6DE3-DCBB-494F-B621-4435A49C466D%40anaconda.com.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

https://bokeh.pydata.org/en/latest/docs/installation.html#developer-builds

···

2018-04-19 0:13 GMT+03:00 Bryan Van de ven [email protected]:

This was a bug that was recently fixed on master:

    [https://github.com/bokeh/bokeh/issues/7462](https://github.com/bokeh/bokeh/issues/7462)

You can try dev build immediately, or wait for the next release.

Thanks,

Bryan

On Apr 18, 2018, at 01:00, SinniK Al [email protected] wrote:

Hello there,

I am trying to modify this example (http://bokeh.pydata.org/en/latest/docs/gallery/brewer.html), so as to have timedates or strings on the x-axis instead of numeric values. I have tried the modifications recommended at SO (https://stackoverflow.com/questions/42426410/bokeh-patches-plot-with-dates-as-x-axis-shifts-the-ticks-one-to-the-right?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa), making the needed changes and so the code that I’ve been trying to implement is:

from bokeh.plotting import figure, show, output_file

from bokeh.palettes import brewer

from bokeh.io import show

from bokeh.models import FactorRange

N = 20

categories = [‘y’ + str(x) for x in range(10)]

data = {}

data[‘x’] = np.arange(1,N+1)

for cat in categories:

data[cat] = np.random.randint(10, 100, size=N)

df = pd.DataFrame(data)

df = df.set_index([‘x’])

def stacked(df, categories):

areas = dict()
last = np.zeros(len(df[categories[0]]))
for cat in categories:
    next = last + df[cat]
    areas[cat] = np.hstack((last[::-1], next))
    last = next
return areas

areas = stacked(df, categories)

colors = brewer[“Spectral”][len(areas)]

x2 = np.hstack((data[‘x’][::-1], data[‘x’]))

timesteps = [str(x.date()) for x in pd.date_range(‘1950-01-01’, ‘1951-08-01’, freq=‘MS’)]

p = figure(x_range=FactorRange(factors=timesteps), y_range=(0, 800))

p.grid.minor_grid_line_color = ‘#eeeeee

p.patches([x2] * len(areas), [areas[cat] for cat in categories],

      color=colors, alpha=0.8, line_color=None)

p.xaxis.major_label_orientation = np.pi/4

show§

However, this is not working anymore.

Does anyone have any idea on some possible fixes?

Thanks

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/5769d4ab-91dd-401e-843a-4975574df34f%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/808B6DE3-DCBB-494F-B621-4435A49C466D%40anaconda.com.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Thanks!!

···

2018-04-19 15:25 GMT+03:00 Bryan Van de ven [email protected]:

https://bokeh.pydata.org/en/latest/docs/installation.html#developer-builds

On Apr 19, 2018, at 01:46, SinniK Al [email protected] wrote:

Thank you Bryan.

How could I try dev build?

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAON2cBbwvuwVDrsbT4NCVLSyPYAYvO%3DN_twf%2BfcBNETaowzudg%40mail.gmail.com.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/2D97E73D-BF10-4F97-93D1-FEB83FE4C5CF%40anaconda.com.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

2018-04-19 0:13 GMT+03:00 Bryan Van de ven [email protected]:

This was a bug that was recently fixed on master:

    [https://github.com/bokeh/bokeh/issues/7462](https://github.com/bokeh/bokeh/issues/7462)

You can try dev build immediately, or wait for the next release.

Thanks,

Bryan

On Apr 18, 2018, at 01:00, SinniK Al [email protected] wrote:

Hello there,

I am trying to modify this example (http://bokeh.pydata.org/en/latest/docs/gallery/brewer.html), so as to have timedates or strings on the x-axis instead of numeric values. I have tried the modifications recommended at SO (https://stackoverflow.com/questions/42426410/bokeh-patches-plot-with-dates-as-x-axis-shifts-the-ticks-one-to-the-right?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa), making the needed changes and so the code that I’ve been trying to implement is:

from bokeh.plotting import figure, show, output_file

from bokeh.palettes import brewer

from bokeh.io import show

from bokeh.models import FactorRange

N = 20

categories = [‘y’ + str(x) for x in range(10)]

data = {}

data[‘x’] = np.arange(1,N+1)

for cat in categories:

data[cat] = np.random.randint(10, 100, size=N)

df = pd.DataFrame(data)

df = df.set_index([‘x’])

def stacked(df, categories):

areas = dict()
last = np.zeros(len(df[categories[0]]))
for cat in categories:
    next = last + df[cat]
    areas[cat] = np.hstack((last[::-1], next))
    last = next
return areas

areas = stacked(df, categories)

colors = brewer[“Spectral”][len(areas)]

x2 = np.hstack((data[‘x’][::-1], data[‘x’]))

timesteps = [str(x.date()) for x in pd.date_range(‘1950-01-01’, ‘1951-08-01’, freq=‘MS’)]

p = figure(x_range=FactorRange(factors=timesteps), y_range=(0, 800))

p.grid.minor_grid_line_color = ‘#eeeeee

p.patches([x2] * len(areas), [areas[cat] for cat in categories],

      color=colors, alpha=0.8, line_color=None)

p.xaxis.major_label_orientation = np.pi/4

show§

However, this is not working anymore.

Does anyone have any idea on some possible fixes?

Thanks

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/5769d4ab-91dd-401e-843a-4975574df34f%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/808B6DE3-DCBB-494F-B621-4435A49C466D%40anaconda.com.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.