New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

curdoc().theme = Theme(json=yaml.load()) is not applied to charts when used in Jupyter notebook #4722

Closed
user32000 opened this Issue Jul 1, 2016 · 4 comments

Comments

Projects
None yet
5 participants
@user32000

user32000 commented Jul 1, 2016

Running the color slider example in a Jupyter notebook it seems that the defaults defined in the theme are not applied

@bryevdv bryevdv added the type: bug label Jul 2, 2016

@bryevdv bryevdv added this to the short-term milestone Jul 2, 2016

@cedricporter

This comment has been minimized.

Show comment
Hide comment
@cedricporter

cedricporter Sep 1, 2016

same problem

cedricporter commented Sep 1, 2016

same problem

@rubik

This comment has been minimized.

Show comment
Hide comment
@rubik

rubik Sep 28, 2016

Same. I've tried everything, from curdoc().theme = Theme(...) to bokeh.themes.default = Theme(...), but nothing seems to be working.

Any ideas?

rubik commented Sep 28, 2016

Same. I've tried everything, from curdoc().theme = Theme(...) to bokeh.themes.default = Theme(...), but nothing seems to be working.

Any ideas?

@djpugh

This comment has been minimized.

Show comment
Hide comment
@djpugh

djpugh Nov 21, 2016

Contributor

As with #4952 - It looks like it may be the use of with _ModelInEmptyDocument(model): in notebook_div - I assume this is where the embedding occurs

Contributor

djpugh commented Nov 21, 2016

As with #4952 - It looks like it may be the use of with _ModelInEmptyDocument(model): in notebook_div - I assume this is where the embedding occurs

@jsignell jsignell referenced this issue Feb 28, 2017

Merged

Fix embed themed models #5932

3 of 3 tasks complete

@bryevdv bryevdv closed this in #5932 Mar 1, 2017

@bryevdv bryevdv modified the milestones: 0.12.5, short-term Mar 1, 2017

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Oct 14, 2017

First of all, awesome work. Bokeh sets the current standard thanks to all your efforts.

Second, I am still running into the issue of not having a theme affect the style of the notebook display with version 0.12.9. I would expect the following code to produce a plot with a pink background:

from bokeh.plotting import figure 
from bokeh.io import output_notebook, show, curdoc
from bokeh.themes import Theme, default
import yaml

output_notebook()
theme = Theme(json={'attrs': {'Plot': {'background_fill_color': 'pink'}}})
curdoc().theme = theme

x1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
y1 = [0, 8, 2, 4, 6, 9, 5, 6, 25, 28, 4]

p = figure(title='PINK PLOT')
p.scatter(x1, y1)
show(p)

Looking at the _ModelInEmptyDocument context manager in embed.py, it appears that the new empty_doc forgets about the applied theme. Changing

    for ref in model.references():
        ref._document = None
    empty_doc = Document()
    empty_doc.add_root(model)

to

    for ref in model.references():
        ref._document = None
    empty_doc = Document(theme=doc.theme)
    empty_doc.add_root(model)

produces the desired results.

First time posting here. I apologize if I am breaking any protocols. Thank you.

ghost commented Oct 14, 2017

First of all, awesome work. Bokeh sets the current standard thanks to all your efforts.

Second, I am still running into the issue of not having a theme affect the style of the notebook display with version 0.12.9. I would expect the following code to produce a plot with a pink background:

from bokeh.plotting import figure 
from bokeh.io import output_notebook, show, curdoc
from bokeh.themes import Theme, default
import yaml

output_notebook()
theme = Theme(json={'attrs': {'Plot': {'background_fill_color': 'pink'}}})
curdoc().theme = theme

x1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
y1 = [0, 8, 2, 4, 6, 9, 5, 6, 25, 28, 4]

p = figure(title='PINK PLOT')
p.scatter(x1, y1)
show(p)

Looking at the _ModelInEmptyDocument context manager in embed.py, it appears that the new empty_doc forgets about the applied theme. Changing

    for ref in model.references():
        ref._document = None
    empty_doc = Document()
    empty_doc.add_root(model)

to

    for ref in model.references():
        ref._document = None
    empty_doc = Document(theme=doc.theme)
    empty_doc.add_root(model)

produces the desired results.

First time posting here. I apologize if I am breaking any protocols. Thank you.

jetilton added a commit to jetilton/bokeh that referenced this issue Mar 23, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment