Update: it may have to do with calling the make_plot() function two different times as opposed to calling it once.
Still looking into it though.
I made the following small change to my code and now I have two matching div and script tags. However, I still have a weird error and the graph output is entirely blank.
# returns tags for a given part as a list :: I think this is the source of the error some how
def return_tags(plt):
scpt, dv = components(plt)
parts = [scpt, dv]
return parts
# generates the plots and returns
def make_plot(lst):
plot = figure()
xStr = ""
yStr = ""
for point in lst:
xStr += str(point[0]) + ","
yStr += str(point[1]) + ","
xStr = xStr[:-1]
yStr = yStr[:-1]
plot.circle(xStr, yStr)
return return_tags(plot)
# this list makes sure that its the same call of the function ergo the same ids being used on the script and div tags
lst = make_plot([[1,2], [3,4]])
print(lst[0])
print(lst[1])
**OUTPUT:**
ERROR:/anaconda/lib/python2.7/site-packages/bokeh/validation/check.pyc:E-1001 (BAD_COLUMN_NAME): Glyph refers to nonexistent column name: 1, 2 [renderer: GlyphRenderer, ViewModel:GlyphRenderer, ref _id: c385dd2d-5bcc-4157-9c64-39bc62f40bd7]
<script type="text/javascript">
Bokeh.$(function() {
var all_models = [{"attributes": {"doc": null, "id": "b534e75c-9eb6-4932-ab3d-59559371dfb6", "tags": []}, "type": "BasicTickFormatter", "id": "b534e75c-9eb6-4932-ab3d-59559371dfb6"}, {"attributes": {"plot": {"subtype": "Figure", "type": "Plot", "id": "55a73cdc-2d43-4918-afeb-d2c7c00a58a5"}, "tags": [], "doc": null, "dimension": 1, "ticker": {"type": "BasicTicker", "id": "b3598f8d-e582-4de3-9d3b-02633945972a"}, "id": "2f394192-b9fc-4632-8772-d480419df844"}, "type": "Grid", "id": "2f394192-b9fc-4632-8772-d480419df844"}, {"attributes": {"plot": {"subtype": "Figure", "type": "Plot", "id": "55a73cdc-2d43-4918-afeb-d2c7c00a58a5"}, "dimensions": ["width", "height"], "tags": [], "doc": null, "id": "b377877a-e6f4-4061-a2ea-b675825191f7"}, "type": "PanTool", "id": "b377877a-e6f4-4061-a2ea-b675825191f7"}, {"attributes": {"plot": {"subtype": "Figure", "type": "Plot", "id": "55a73cdc-2d43-4918-afeb-d2c7c00a58a5"}, "dimensions": ["width", "height"], "tags": [], "doc": null, "id": "1dabada1-6393-4b9f-b81f-0b51c061376e"}, "type": "WheelZoomTool", "id": "1dabada1-6393-4b9f-b81f-0b51c061376e"}, {"attributes": {"plot": {"subtype": "Figure", "type": "Plot", "id": "55a73cdc-2d43-4918-afeb-d2c7c00a58a5"}, "dimensions": ["width", "height"], "tags": [], "doc": null, "id": "4d01cd27-93b3-4ad9-9042-cb0b13eb1b4e"}, "type": "BoxZoomTool", "id": "4d01cd27-93b3-4ad9-9042-cb0b13eb1b4e"}, {"attributes": {"plot": {"subtype": "Figure", "type": "Plot", "id": "55a73cdc-2d43-4918-afeb-d2c7c00a58a5"}, "tags": [], "doc": null, "id": "4cddfd58-027c-4319-b6f7-d07bc466a425"}, "type": "PreviewSaveTool", "id": "4cddfd58-027c-4319-b6f7-d07bc466a425"}, {"attributes": {"plot": {"subtype": "Figure", "type": "Plot", "id": "55a73cdc-2d43-4918-afeb-d2c7c00a58a5"}, "tags": [], "doc": null, "id": "f81b83d6-5dcc-48df-be87-106bdf3e5238"}, "type": "ResizeTool", "id": "f81b83d6-5dcc-48df-be87-106bdf3e5238"}, {"attributes": {"plot": {"subtype": "Figure", "type": "Plot", "id": "55a73cdc-2d43-4918-afeb-d2c7c00a58a5"}, "tags": [], "doc": null, "id": "6b181c9a-ec96-4ab6-acb6-d8306f188f76"}, "type": "ResetTool", "id": "6b181c9a-ec96-4ab6-acb6-d8306f188f76"}, {"attributes": {"plot": {"subtype": "Figure", "type": "Plot", "id": "55a73cdc-2d43-4918-afeb-d2c7c00a58a5"}, "tags": [], "doc": null, "id": "ea7a3361-e88c-4860-b7da-ef2e4991d94b"}, "type": "HelpTool", "id": "ea7a3361-e88c-4860-b7da-ef2e4991d94b"}, {"attributes": {"line_color": {"value": "#1f77b4"}, "line_alpha": {"value": 0.1}, "fill_color": {"value": "#1f77b4"}, "tags": [], "doc": null, "fill_alpha": {"value": 0.1}, "y": {"field": "2"}, "x": {"field": "1"}, "id": "648f472c-db34-4741-bab3-2ed27651a79a"}, "type": "Circle", "id": "648f472c-db34-4741-bab3-2ed27651a79a"}, {"attributes": {"line_color": {"value": "#1f77b4"}, "line_alpha": {"value": 1.0}, "fill_color": {"value": "#1f77b4"}, "tags": [], "doc": null, "fill_alpha": {"value": 1.0}, "y": {"field": "2"}, "x": {"field": "1"}, "id": "12a3780a-d041-49b2-9022-ec37d65bd1f1"}, "type": "Circle", "id": "12a3780a-d041-49b2-9022-ec37d65bd1f1"}, {"attributes": {"nonselection_glyph": {"type": "Circle", "id": "648f472c-db34-4741-bab3-2ed27651a79a"}, "data_source": {"type": "ColumnDataSource", "id": "ae760389-a328-4aee-912c-c26ca72f221c"}, "tags": [], "doc": null, "selection_glyph": null, "id": "c385dd2d-5bcc-4157-9c64-39bc62f40bd7", "glyph": {"type": "Circle", "id": "12a3780a-d041-49b2-9022-ec37d65bd1f1"}}, "type": "GlyphRenderer", "id": "c385dd2d-5bcc-4157-9c64-39bc62f40bd7"}, {"attributes": {"column_names": [], "tags": [], "doc": null, "selected": {"2d": {"indices": []}, "1d": {"indices": []}, "0d": {"indices": [], "flag": false}}, "callback": null, "data": {}, "id": "ae760389-a328-4aee-912c-c26ca72f221c"}, "type": "ColumnDataSource", "id": "ae760389-a328-4aee-912c-c26ca72f221c"}, {"subtype": "Figure", "type": "Plot", "id": "55a73cdc-2d43-4918-afeb-d2c7c00a58a5", "attributes": {"x_range": {"type": "DataRange1d", "id": "fe24a8d4-cdd0-498d-b98d-6ed14c2b2dae"}, "right": [], "tags": [], "y_range": {"type": "DataRange1d", "id": "b36d30a6-d39b-425f-96fb-6142299358f7"}, "renderers": [{"type": "LinearAxis", "id": "79ebbc17-9ca5-476a-8578-039320b74a1a"}, {"type": "Grid", "id": "27c97d5a-ba92-4f9b-b81b-02790fd66391"}, {"type": "LinearAxis", "id": "66ca2598-f2d4-4bf7-bcb8-769c358f9281"}, {"type": "Grid", "id": "2f394192-b9fc-4632-8772-d480419df844"}, {"type": "GlyphRenderer", "id": "c385dd2d-5bcc-4157-9c64-39bc62f40bd7"}], "extra_y_ranges": {}, "extra_x_ranges": {}, "tool_events": {"type": "ToolEvents", "id": "782bb11c-fc7e-492e-a483-e49d486c0945"}, "above": [], "doc": null, "id": "55a73cdc-2d43-4918-afeb-d2c7c00a58a5", "tools": [{"type": "PanTool", "id": "b377877a-e6f4-4061-a2ea-b675825191f7"}, {"type": "WheelZoomTool", "id": "1dabada1-6393-4b9f-b81f-0b51c061376e"}, {"type": "BoxZoomTool", "id": "4d01cd27-93b3-4ad9-9042-cb0b13eb1b4e"}, {"type": "PreviewSaveTool", "id": "4cddfd58-027c-4319-b6f7-d07bc466a425"}, {"type": "ResizeTool", "id": "f81b83d6-5dcc-48df-be87-106bdf3e5238"}, {"type": "ResetTool", "id": "6b181c9a-ec96-4ab6-acb6-d8306f188f76"}, {"type": "HelpTool", "id": "ea7a3361-e88c-4860-b7da-ef2e4991d94b"}], "below": [{"type": "LinearAxis", "id": "79ebbc17-9ca5-476a-8578-039320b74a1a"}], "left": [{"type": "LinearAxis", "id": "66ca2598-f2d4-4bf7-bcb8-769c358f9281"}]}}, {"attributes": {"geometries": [], "tags": [], "doc": null, "id": "782bb11c-fc7e-492e-a483-e49d486c0945"}, "type": "ToolEvents", "id": "782bb11c-fc7e-492e-a483-e49d486c0945"}, {"attributes": {"tags": [], "doc": null, "renderers": [], "callback": null, "names": [], "id": "fe24a8d4-cdd0-498d-b98d-6ed14c2b2dae"}, "type": "DataRange1d", "id": "fe24a8d4-cdd0-498d-b98d-6ed14c2b2dae"}, {"attributes": {"tags": [], "doc": null, "renderers": [], "callback": null, "names": [], "id": "b36d30a6-d39b-425f-96fb-6142299358f7"}, "type": "DataRange1d", "id": "b36d30a6-d39b-425f-96fb-6142299358f7"}, {"attributes": {"plot": {"subtype": "Figure", "type": "Plot", "id": "55a73cdc-2d43-4918-afeb-d2c7c00a58a5"}, "tags": [], "doc": null, "formatter": {"type": "BasicTickFormatter", "id": "9a2f1915-efb3-494e-80c6-d1fe01fb06d7"}, "ticker": {"type": "BasicTicker", "id": "94bd3e16-330e-4b6e-940f-ae9e3ff60302"}, "id": "79ebbc17-9ca5-476a-8578-039320b74a1a"}, "type": "LinearAxis", "id": "79ebbc17-9ca5-476a-8578-039320b74a1a"}, {"attributes": {"tags": [], "doc": null, "mantissas": [2, 5, 10], "id": "94bd3e16-330e-4b6e-940f-ae9e3ff60302", "num_minor_ticks": 5}, "type": "BasicTicker", "id": "94bd3e16-330e-4b6e-940f-ae9e3ff60302"}, {"attributes": {"doc": null, "id": "9a2f1915-efb3-494e-80c6-d1fe01fb06d7", "tags": []}, "type": "BasicTickFormatter", "id": "9a2f1915-efb3-494e-80c6-d1fe01fb06d7"}, {"attributes": {"plot": {"subtype": "Figure", "type": "Plot", "id": "55a73cdc-2d43-4918-afeb-d2c7c00a58a5"}, "tags": [], "doc": null, "dimension": 0, "ticker": {"type": "BasicTicker", "id": "94bd3e16-330e-4b6e-940f-ae9e3ff60302"}, "id": "27c97d5a-ba92-4f9b-b81b-02790fd66391"}, "type": "Grid", "id": "27c97d5a-ba92-4f9b-b81b-02790fd66391"}, {"attributes": {"plot": {"subtype": "Figure", "type": "Plot", "id": "55a73cdc-2d43-4918-afeb-d2c7c00a58a5"}, "tags": [], "doc": null, "formatter": {"type": "BasicTickFormatter", "id": "b534e75c-9eb6-4932-ab3d-59559371dfb6"}, "ticker": {"type": "BasicTicker", "id": "b3598f8d-e582-4de3-9d3b-02633945972a"}, "id": "66ca2598-f2d4-4bf7-bcb8-769c358f9281"}, "type": "LinearAxis", "id": "66ca2598-f2d4-4bf7-bcb8-769c358f9281"}, {"attributes": {"tags": [], "doc": null, "mantissas": [2, 5, 10], "id": "b3598f8d-e582-4de3-9d3b-02633945972a", "num_minor_ticks": 5}, "type": "BasicTicker", "id": "b3598f8d-e582-4de3-9d3b-02633945972a"}];
Bokeh.load_models(all_models);
var plots = [{'modeltype': 'Plot', 'elementid': '#fed099c3-e959-4d2a-a83c-27aa0c654dd3', 'modelid': '55a73cdc-2d43-4918-afeb-d2c7c00a58a5'}];
for (idx in plots) {
var plot = plots[idx];
var model = Bokeh.Collections(plot.modeltype).get(plot.modelid);
Bokeh.logger.info('Realizing plot:')
Bokeh.logger.info(' - modeltype: ' + plot.modeltype);
Bokeh.logger.info(' - modelid: ' + plot.modelid);
Bokeh.logger.info(' - elementid: ' + plot.elementid);
var view = new model.default_view({
model: model,
el: plot.elementid
});
Bokeh.index[plot.modelid] = view;
}
});
</script>
<div class="plotdiv" id="fed099c3-e959-4d2a-a83c-27aa0c654dd3"></div>