On Feb 2, 2016, at 10:40 AM, [email protected] wrote:
Using your example code, I get the error
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-3-39a5786d354e> in <module>()
3 from bokeh.document import Document
4 from bokeh.io import curstate
----> 5 curstate().autoadd = False
6 p = Bar(df, 'cyl', values='mpg', title="Total MPG by CYL", group='yr', legend='top_right')
7 mydoc = Document()
AttributeError: can't set attribute
On Monday, February 1, 2016 at 4:29:20 PM UTC-6, Bryan Van de ven wrote:
For the moment, you need to explicitly turn off the "autoadd" feature, which automatically causes the Chart to add itself to the default-created and automatically-available "current documemt". Once you do that, you can create your plot and add it to you explicit/custom document. Note that you also want to use "add_root" now:
In [1]: from bokeh.charts import Bar, output_file, show
In [2]: from bokeh.sampledata.autompg import autompg as df
In [3]: from bokeh.document import Document
In [4]: from bokeh.io import curstate
In [5]: curstate().autoadd = False
In [6]: p = Bar(df, 'cyl', values='mpg', title="Total MPG by CYL", group='yr', legend='top_right')
In [7]: mydoc = Document()
In [8]: mydoc.add_root(p)
The implicit default document is a very useful concept for a great many use cases, but as you can see it makes some other use-cases a bit more clunky. As with many things, there is always a trade-off. We are still working to find the right balance, or if there is a way to help improve this use case without sacrificing the general ease of use the current document affords.
Thanks,
Bryan
> On Feb 1, 2016, at 1:36 PM, zor...@gmail.com wrote:
>
> from bokeh.charts import Bar, output_file, show
> from bokeh.sampledata.autompg import autompg as df
> from bokeh.document import Document
>
> p = Bar(df, 'cyl', values='mpg', title="Total MPG by CYL", group='yr', legend='top_right')
>
> mydoc = Document()
> mydoc.add(p)
>
> Gives the error:
> RuntimeError: Models must be owned by only a single document, <bokeh.models.sources.ColumnDataSource object at 0x15446bc10> is already in a doc
> This used to work in previous versions of Bokeh, and I have no idea how to accomplish this now.
>
> --
> 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 bokeh+un...@continuum.io.
> To post to this group, send email to bo...@continuum.io.
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/5cb00f1c-1b5b-424d-8ba7-ebf25e842c5b%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/a23be443-5039-47a6-9c59-9128284549b2%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.