Embedding multiple plots and charts with the same layout, (BOTh_CHILD_AND_ROOT) error.

Good afternoon everyone.

It’s been three days since I began using Bokeh, and I like the work it’s doing for me to build some charts.

Yet I experienced a problem yesterday for which I found no real solution.

I described everything in StackOverflow, but since there’s not much people to see, comment and answer Bokeh-oriented question there, I’m posting my problem here too.

I hope someone will know what I’m doing wrong. Thanks for your help.

Hi,

···

The code in the SO post looks like its from the examples not your actual embed code.

Can u share your actual embed code.

Off the cuff I’d suggest trying uppercase Figure instead of figure.

Best,

Sarah Bird
[email protected]

On Apr 22, 2016, at 7:44 AM, [email protected] wrote:

Good afternoon everyone.

It’s been three days since I began using Bokeh, and I like the work it’s doing for me to build some charts.

Yet I experienced a problem yesterday for which I found no real solution.

http://stackoverflow.com/questions/36790288/bokeh-ploting-multiples-charts-in-a-layout-throws-error-both-child-and-root

I described everything in StackOverflow, but since there’s not much people to see, comment and answer Bokeh-oriented question there, I’m posting my problem here too.

I hope someone will know what I’m doing wrong. Thanks for your help.

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/acfb9f04-ddec-4a22-be9d-dedf7408172a%40continuum.io.

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

The code in my SO post is indeed the one from the example, because even the example isn’t working and is throwing the error (BOTH_CHILD_AND_ROOT) !

My own code may have other problems which I didn’t want people to focus on.

Anyway, here goes my own code.

def bokeh_temperature_scatter_plot():

    data_set = CSVModel.objects.all()
    x_data = []
    y_data = []

    for Model in data_set:
        x_data.append(Model.cpu)
        y_data.append(Model.temperature)

    dic = {'cpu': x_data, 'temperature': y_data}

    df = pd.DataFrame(dic)

    p = Scatter(df, x='cpu', y='temperature', title=u'Temperature vs CPU', color=u'navy', xlabel=u'CPU in MB'\
                , ylabel=u'Temperature °C' )
    colors = RdBu9
    box_cold = BoxAnnotation(plot=p, top=50, fill_alpha=0.1, fill_color=colors[0])

    box_normal = BoxAnnotation(plot=p, bottom=50, top=100, fill_alpha=0.1, fill_color=colors[4])

    box_hot = BoxAnnotation(plot=p, bottom=100, fill_alpha=0.1, fill_color=colors[7])

    p.renderers.extend([box_cold, box_normal, box_hot])

    return p


def bokeh_bar_chart_test():

data_set = CSVModel.objects.all()
x_data = []
y_data = []

dic = {'values': {}}

for Model in data_set:
    x_data.append(Model.date)
    y_data.append(Model.cpu)

x_test = [x.strftime("%Y-%m-%d") for x in x_data]

for x in x_test:
    i = x_test.index(x)
    dic['values'][x]=y_data[i]
df = pd.DataFrame(dic)

p = Bar(df, agg='count', values='values', title='Quantity sold by model', color='blue', width = 800,\
        tools=[HoverTool()])

hover = p.select_one(HoverTool)
hover.point_policy = "follow_mouse"
hover.tooltips = [
    ("CPU", "$y"),
    ("Date", "@x")
]

return p

In a python console :

from functions import bokeh_xml_test, bokeh_bar_chart_test

from bokeh.io import vform

form = vform (bokeh_xml_test(),bokeh_bar_chart_test())

show(form)

This only shows a blank page.

Then, if I add an output_file and retrieve an html file and opens it in my browser, the same thing happens. And the same thing if I retrieve javascript et div like that :

javascript, div = components(vform)

and add these in an html file.

Thanks for taking the time to help me solve this.

Ok great.

···

Two things:

  1. we’re making this better so hopefully this won’t be so painful in future

  2. I would suggeste VBox or vplot

  3. use p.add_layout the manually extending renderers

Sarah Bird
[email protected]

On Apr 22, 2016, at 9:19 AM, [email protected] wrote:

The code in my SO post is indeed the one from the example, because even the example isn’t working and is throwing the error (BOTH_CHILD_AND_ROOT) !

My own code may have other problems which I didn’t want people to focus on.

Anyway, here goes my own code.

def bokeh_temperature_scatter_plot():

    data_set = CSVModel.objects.all()
    x_data = []
    y_data = []

    for Model in data_set:
        x_data.append(Model.cpu)
        y_data.append(Model.temperature)

    dic = {'cpu': x_data, 'temperature': y_data}

    df = pd.DataFrame(dic)

    p = Scatter(df, x='cpu', y='temperature', title=u'Temperature vs CPU', color=u'navy', xlabel=u'CPU in MB'\
                , ylabel=u'Temperature °C' )
    colors = RdBu9
    box_cold = BoxAnnotation(plot=p, top=50, fill_alpha=0.1, fill_color=colors[0])

    box_normal = BoxAnnotation(plot=p, bottom=50, top=100, fill_alpha=0.1, fill_color=colors[4])

    box_hot = BoxAnnotation(plot=p, bottom=100, fill_alpha=0.1, fill_color=colors[7])

    p.renderers.extend([box_cold, box_normal, box_hot])

    return p



def bokeh_bar_chart_test():

data_set = CSVModel.objects.all()
x_data = []
y_data = []

dic = {'values': {}}

for Model in data_set:
    x_data.append(Model.date)
    y_data.append(Model.cpu)

x_test = [x.strftime("%Y-%m-%d") for x in x_data]

for x in x_test:
    i = x_test.index(x)
    dic['values'][x]=y_data[i]
df = pd.DataFrame(dic)

p = Bar(df, agg='count', values='values', title='Quantity sold by model', color='blue', width = 800,\
        tools=[HoverTool()])

hover = p.select_one(HoverTool)
hover.point_policy = "follow_mouse"
hover.tooltips = [
    ("CPU", "$y"),
    ("Date", "@x")
]

return p

In a python console :

from functions import bokeh_xml_test, bokeh_bar_chart_test

from bokeh.io import vform

form = vform (bokeh_xml_test(),bokeh_bar_chart_test())

show(form)

This only shows a blank page.

Then, if I add an output_file and retrieve an html file and opens it in my browser, the same thing happens. And the same thing if I retrieve javascript et div like that :

javascript, div = components(vform)

and add these in an html file.

Thanks for taking the time to help me solve this.

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/4da1c17e-6563-42d0-a01a-8126d9b5b515%40continuum.io.

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

Well, thanks for your help.

It is still not working though, but that’s not a huge problem, I just asked because it would be cleaner in my main program and would perhaps requires less ressources.

I’ll look after your next release and see there if it works better.

···

Le vendredi 22 avril 2016 20:44:22 UTC+2, Sarah Bird a écrit :

Ok great.

Two things:

  1. we’re making this better so hopefully this won’t be so painful in future
  1. I would suggeste VBox or vplot
  1. use p.add_layout the manually extending renderers

Sarah Bird
[email protected]

On Apr 22, 2016, at 9:19 AM, [email protected] wrote:

The code in my SO post is indeed the one from the example, because even the example isn’t working and is throwing the error (BOTH_CHILD_AND_ROOT) !

My own code may have other problems which I didn’t want people to focus on.

Anyway, here goes my own code.

def bokeh_temperature_scatter_plot():

    data_set = CSVModel.objects.all()
    x_data = []
    y_data = []

    for Model in data_set:
        x_data.append(Model.cpu)
        y_data.append(Model.temperature)

    dic = {'cpu': x_data, 'temperature': y_data}

    df = pd.DataFrame(dic)

    p = Scatter(df, x='cpu', y='temperature', title=u'Temperature vs CPU', color=u'navy', xlabel=u'CPU in MB'\
                , ylabel=u'Temperature °C' )
    colors = RdBu9
    box_cold = BoxAnnotation(plot=p, top=50, fill_alpha=0.1, fill_color=colors[0])

    box_normal = BoxAnnotation(plot=p, bottom=50, top=100, fill_alpha=0.1, fill_color=colors[4])

    box_hot = BoxAnnotation(plot=p, bottom=100, fill_alpha=0.1, fill_color=colors[7])

    p.renderers.extend([box_cold, box_normal, box_hot])

    return p



def bokeh_bar_chart_test():

data_set = CSVModel.objects.all()
x_data = []
y_data = []

dic = {'values': {}}

for Model in data_set:
    x_data.append(Model.date)
    y_data.append(Model.cpu)

x_test = [x.strftime("%Y-%m-%d") for x in x_data]

for x in x_test:
    i = x_test.index(x)
    dic['values'][x]=y_data[i]
df = pd.DataFrame(dic)

p = Bar(df, agg='count', values='values', title='Quantity sold by model', color='blue', width = 800,\
        tools=[HoverTool()])

hover = p.select_one(HoverTool)
hover.point_policy = "follow_mouse"
hover.tooltips = [
    ("CPU", "$y"),
    ("Date", "@x")
]

return p

In a python console :

from functions import bokeh_xml_test, bokeh_bar_chart_test

from bokeh.io import vform

form = vform (bokeh_xml_test(),bokeh_bar_chart_test())

show(form)

This only shows a blank page.

Then, if I add an output_file and retrieve an html file and opens it in my browser, the same thing happens. And the same thing if I retrieve javascript et div like that :

javascript, div = components(vform)

and add these in an html file.

Thanks for taking the time to help me solve this.

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/4da1c17e-6563-42d0-a01a-8126d9b5b515%40continuum.io.

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