How can I speed up the page load of plots created in Bokeh?












2














After I run my code, the page opens up and for 13 seconds a blank page shows up, and after that, the expected plots.



Is there a way to speed this up? (13 seconds, user wise is sadly too long)



The code produces 44 plots, in two columns(2n loop), differ by parameter (1st loop) and then differ by tool name (3 rd loop)



Also if bokeh, isnt the right tool for this, would happily open to hear a way to plot interactive plots, preferably with python



This is the code:



dateparse = lambda x: pd.datetime.strptime(x, '%Y-%m-%dT%H:%M:%S')

df = pd.read_csv("LUSU.csv",parse_dates=['PM_START_DATE'], date_parser=dateparse)

df.head()
print("time elapsed: {:.2f}s".format(time.time() - start_time))
x = df['PM_START_DATE']
y = df['TASK_VALUE']
tool=df['ENTITY']
tool_list=df['ENTITY'].unique()
param_list=df['PARAMETER'].unique()
#
print("time elapsed: {:.2f}s".format(time.time() - start_time))
colors = itertools.cycle(Spectral11)
output_file('LUSU.html', mode="cdn")
for i in range(0,44,2):
row =
for _ in range(2):
p = figure(title=param_list[i], x_axis_label='date', y_axis_label='chart value', x_axis_type="datetime", toolbar_location="below")
for j in range(len(tool_list)):
df1=((df['PARAMETER']==param_list[i] )& (df['ENTITY']==tool_list[j] ))
source = ColumnDataSource(data=dict(x=x.loc[df1], y=y.loc[df1], tool=tool.loc[df1]))
p.line(x='x', y='y',legend='tool', source=source)
p.scatter(x='x', y='y',legend='tool',size=10,color=next(colors), source=source)
p.add_tools(HoverTool(tooltips=[("Entity", "@tool"), ("Chart Value", "@y{%0.2f}"), ("Date", "@x{%F}")], formatters={"x": "datetime", "y": 'printf'}))
#p.xaxis.formatter = DatetimeTickFormatter(days=["%m/%d/%Y"])
p.legend.location = "top_right"
p.legend.click_policy = "mute"
row.append(p)
i = i + 1
grid.append(row)

fig=layout(grid)
reset_output()

show(fig)









share|improve this question
























  • Is the script still iterating in the for loop or it is stuck in the "show" function when the page is blank? Could you check it? If the iteration is the problem you may use some multiprocessing or multithreading python module
    – ChesuCR
    Nov 20 '18 at 13:14










  • Anyway I reckon bokeh is not prepared to work with so many plots. Besides, if many axis share some range, I am afraid that panning and zooming is going to be almost imposible. Let me know if you get this working faster because I am really interested
    – ChesuCR
    Nov 20 '18 at 13:17










  • Ah! If you finally use multiprocessing module take into account this. You should use this environment variable BOKEH_SIMPLE_IDS=no
    – ChesuCR
    Nov 20 '18 at 13:19
















2














After I run my code, the page opens up and for 13 seconds a blank page shows up, and after that, the expected plots.



Is there a way to speed this up? (13 seconds, user wise is sadly too long)



The code produces 44 plots, in two columns(2n loop), differ by parameter (1st loop) and then differ by tool name (3 rd loop)



Also if bokeh, isnt the right tool for this, would happily open to hear a way to plot interactive plots, preferably with python



This is the code:



dateparse = lambda x: pd.datetime.strptime(x, '%Y-%m-%dT%H:%M:%S')

df = pd.read_csv("LUSU.csv",parse_dates=['PM_START_DATE'], date_parser=dateparse)

df.head()
print("time elapsed: {:.2f}s".format(time.time() - start_time))
x = df['PM_START_DATE']
y = df['TASK_VALUE']
tool=df['ENTITY']
tool_list=df['ENTITY'].unique()
param_list=df['PARAMETER'].unique()
#
print("time elapsed: {:.2f}s".format(time.time() - start_time))
colors = itertools.cycle(Spectral11)
output_file('LUSU.html', mode="cdn")
for i in range(0,44,2):
row =
for _ in range(2):
p = figure(title=param_list[i], x_axis_label='date', y_axis_label='chart value', x_axis_type="datetime", toolbar_location="below")
for j in range(len(tool_list)):
df1=((df['PARAMETER']==param_list[i] )& (df['ENTITY']==tool_list[j] ))
source = ColumnDataSource(data=dict(x=x.loc[df1], y=y.loc[df1], tool=tool.loc[df1]))
p.line(x='x', y='y',legend='tool', source=source)
p.scatter(x='x', y='y',legend='tool',size=10,color=next(colors), source=source)
p.add_tools(HoverTool(tooltips=[("Entity", "@tool"), ("Chart Value", "@y{%0.2f}"), ("Date", "@x{%F}")], formatters={"x": "datetime", "y": 'printf'}))
#p.xaxis.formatter = DatetimeTickFormatter(days=["%m/%d/%Y"])
p.legend.location = "top_right"
p.legend.click_policy = "mute"
row.append(p)
i = i + 1
grid.append(row)

fig=layout(grid)
reset_output()

show(fig)









share|improve this question
























  • Is the script still iterating in the for loop or it is stuck in the "show" function when the page is blank? Could you check it? If the iteration is the problem you may use some multiprocessing or multithreading python module
    – ChesuCR
    Nov 20 '18 at 13:14










  • Anyway I reckon bokeh is not prepared to work with so many plots. Besides, if many axis share some range, I am afraid that panning and zooming is going to be almost imposible. Let me know if you get this working faster because I am really interested
    – ChesuCR
    Nov 20 '18 at 13:17










  • Ah! If you finally use multiprocessing module take into account this. You should use this environment variable BOKEH_SIMPLE_IDS=no
    – ChesuCR
    Nov 20 '18 at 13:19














2












2








2


1





After I run my code, the page opens up and for 13 seconds a blank page shows up, and after that, the expected plots.



Is there a way to speed this up? (13 seconds, user wise is sadly too long)



The code produces 44 plots, in two columns(2n loop), differ by parameter (1st loop) and then differ by tool name (3 rd loop)



Also if bokeh, isnt the right tool for this, would happily open to hear a way to plot interactive plots, preferably with python



This is the code:



dateparse = lambda x: pd.datetime.strptime(x, '%Y-%m-%dT%H:%M:%S')

df = pd.read_csv("LUSU.csv",parse_dates=['PM_START_DATE'], date_parser=dateparse)

df.head()
print("time elapsed: {:.2f}s".format(time.time() - start_time))
x = df['PM_START_DATE']
y = df['TASK_VALUE']
tool=df['ENTITY']
tool_list=df['ENTITY'].unique()
param_list=df['PARAMETER'].unique()
#
print("time elapsed: {:.2f}s".format(time.time() - start_time))
colors = itertools.cycle(Spectral11)
output_file('LUSU.html', mode="cdn")
for i in range(0,44,2):
row =
for _ in range(2):
p = figure(title=param_list[i], x_axis_label='date', y_axis_label='chart value', x_axis_type="datetime", toolbar_location="below")
for j in range(len(tool_list)):
df1=((df['PARAMETER']==param_list[i] )& (df['ENTITY']==tool_list[j] ))
source = ColumnDataSource(data=dict(x=x.loc[df1], y=y.loc[df1], tool=tool.loc[df1]))
p.line(x='x', y='y',legend='tool', source=source)
p.scatter(x='x', y='y',legend='tool',size=10,color=next(colors), source=source)
p.add_tools(HoverTool(tooltips=[("Entity", "@tool"), ("Chart Value", "@y{%0.2f}"), ("Date", "@x{%F}")], formatters={"x": "datetime", "y": 'printf'}))
#p.xaxis.formatter = DatetimeTickFormatter(days=["%m/%d/%Y"])
p.legend.location = "top_right"
p.legend.click_policy = "mute"
row.append(p)
i = i + 1
grid.append(row)

fig=layout(grid)
reset_output()

show(fig)









share|improve this question















After I run my code, the page opens up and for 13 seconds a blank page shows up, and after that, the expected plots.



Is there a way to speed this up? (13 seconds, user wise is sadly too long)



The code produces 44 plots, in two columns(2n loop), differ by parameter (1st loop) and then differ by tool name (3 rd loop)



Also if bokeh, isnt the right tool for this, would happily open to hear a way to plot interactive plots, preferably with python



This is the code:



dateparse = lambda x: pd.datetime.strptime(x, '%Y-%m-%dT%H:%M:%S')

df = pd.read_csv("LUSU.csv",parse_dates=['PM_START_DATE'], date_parser=dateparse)

df.head()
print("time elapsed: {:.2f}s".format(time.time() - start_time))
x = df['PM_START_DATE']
y = df['TASK_VALUE']
tool=df['ENTITY']
tool_list=df['ENTITY'].unique()
param_list=df['PARAMETER'].unique()
#
print("time elapsed: {:.2f}s".format(time.time() - start_time))
colors = itertools.cycle(Spectral11)
output_file('LUSU.html', mode="cdn")
for i in range(0,44,2):
row =
for _ in range(2):
p = figure(title=param_list[i], x_axis_label='date', y_axis_label='chart value', x_axis_type="datetime", toolbar_location="below")
for j in range(len(tool_list)):
df1=((df['PARAMETER']==param_list[i] )& (df['ENTITY']==tool_list[j] ))
source = ColumnDataSource(data=dict(x=x.loc[df1], y=y.loc[df1], tool=tool.loc[df1]))
p.line(x='x', y='y',legend='tool', source=source)
p.scatter(x='x', y='y',legend='tool',size=10,color=next(colors), source=source)
p.add_tools(HoverTool(tooltips=[("Entity", "@tool"), ("Chart Value", "@y{%0.2f}"), ("Date", "@x{%F}")], formatters={"x": "datetime", "y": 'printf'}))
#p.xaxis.formatter = DatetimeTickFormatter(days=["%m/%d/%Y"])
p.legend.location = "top_right"
p.legend.click_policy = "mute"
row.append(p)
i = i + 1
grid.append(row)

fig=layout(grid)
reset_output()

show(fig)






python python-3.x plot bokeh interactive






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 '18 at 13:24









ChesuCR

5,55232153




5,55232153










asked Nov 19 '18 at 18:28









Sam ShawSam Shaw

111




111












  • Is the script still iterating in the for loop or it is stuck in the "show" function when the page is blank? Could you check it? If the iteration is the problem you may use some multiprocessing or multithreading python module
    – ChesuCR
    Nov 20 '18 at 13:14










  • Anyway I reckon bokeh is not prepared to work with so many plots. Besides, if many axis share some range, I am afraid that panning and zooming is going to be almost imposible. Let me know if you get this working faster because I am really interested
    – ChesuCR
    Nov 20 '18 at 13:17










  • Ah! If you finally use multiprocessing module take into account this. You should use this environment variable BOKEH_SIMPLE_IDS=no
    – ChesuCR
    Nov 20 '18 at 13:19


















  • Is the script still iterating in the for loop or it is stuck in the "show" function when the page is blank? Could you check it? If the iteration is the problem you may use some multiprocessing or multithreading python module
    – ChesuCR
    Nov 20 '18 at 13:14










  • Anyway I reckon bokeh is not prepared to work with so many plots. Besides, if many axis share some range, I am afraid that panning and zooming is going to be almost imposible. Let me know if you get this working faster because I am really interested
    – ChesuCR
    Nov 20 '18 at 13:17










  • Ah! If you finally use multiprocessing module take into account this. You should use this environment variable BOKEH_SIMPLE_IDS=no
    – ChesuCR
    Nov 20 '18 at 13:19
















Is the script still iterating in the for loop or it is stuck in the "show" function when the page is blank? Could you check it? If the iteration is the problem you may use some multiprocessing or multithreading python module
– ChesuCR
Nov 20 '18 at 13:14




Is the script still iterating in the for loop or it is stuck in the "show" function when the page is blank? Could you check it? If the iteration is the problem you may use some multiprocessing or multithreading python module
– ChesuCR
Nov 20 '18 at 13:14












Anyway I reckon bokeh is not prepared to work with so many plots. Besides, if many axis share some range, I am afraid that panning and zooming is going to be almost imposible. Let me know if you get this working faster because I am really interested
– ChesuCR
Nov 20 '18 at 13:17




Anyway I reckon bokeh is not prepared to work with so many plots. Besides, if many axis share some range, I am afraid that panning and zooming is going to be almost imposible. Let me know if you get this working faster because I am really interested
– ChesuCR
Nov 20 '18 at 13:17












Ah! If you finally use multiprocessing module take into account this. You should use this environment variable BOKEH_SIMPLE_IDS=no
– ChesuCR
Nov 20 '18 at 13:19




Ah! If you finally use multiprocessing module take into account this. You should use this environment variable BOKEH_SIMPLE_IDS=no
– ChesuCR
Nov 20 '18 at 13:19












1 Answer
1






active

oldest

votes


















0














You could try to use webGL to speed it up.
This allows glyphs to render via the GPU.



figure(title=param_list[i], x_axis_label='date', y_axis_label='chart value', x_axis_type="datetime", toolbar_location="below", output_backend="webgl")


More information: https://bokeh.pydata.org/en/latest/docs/user_guide/webgl.html.
Further reading about Bokeh performance issues with a lot of plots: https://github.com/bokeh/bokeh/issues/6294.






share|improve this answer





















  • hi, i tried this, the output is that not all graphs are being plotted, and no change in time is seen
    – Sam Shaw
    Nov 20 '18 at 11:39











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53380632%2fhow-can-i-speed-up-the-page-load-of-plots-created-in-bokeh%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














You could try to use webGL to speed it up.
This allows glyphs to render via the GPU.



figure(title=param_list[i], x_axis_label='date', y_axis_label='chart value', x_axis_type="datetime", toolbar_location="below", output_backend="webgl")


More information: https://bokeh.pydata.org/en/latest/docs/user_guide/webgl.html.
Further reading about Bokeh performance issues with a lot of plots: https://github.com/bokeh/bokeh/issues/6294.






share|improve this answer





















  • hi, i tried this, the output is that not all graphs are being plotted, and no change in time is seen
    – Sam Shaw
    Nov 20 '18 at 11:39
















0














You could try to use webGL to speed it up.
This allows glyphs to render via the GPU.



figure(title=param_list[i], x_axis_label='date', y_axis_label='chart value', x_axis_type="datetime", toolbar_location="below", output_backend="webgl")


More information: https://bokeh.pydata.org/en/latest/docs/user_guide/webgl.html.
Further reading about Bokeh performance issues with a lot of plots: https://github.com/bokeh/bokeh/issues/6294.






share|improve this answer





















  • hi, i tried this, the output is that not all graphs are being plotted, and no change in time is seen
    – Sam Shaw
    Nov 20 '18 at 11:39














0












0








0






You could try to use webGL to speed it up.
This allows glyphs to render via the GPU.



figure(title=param_list[i], x_axis_label='date', y_axis_label='chart value', x_axis_type="datetime", toolbar_location="below", output_backend="webgl")


More information: https://bokeh.pydata.org/en/latest/docs/user_guide/webgl.html.
Further reading about Bokeh performance issues with a lot of plots: https://github.com/bokeh/bokeh/issues/6294.






share|improve this answer












You could try to use webGL to speed it up.
This allows glyphs to render via the GPU.



figure(title=param_list[i], x_axis_label='date', y_axis_label='chart value', x_axis_type="datetime", toolbar_location="below", output_backend="webgl")


More information: https://bokeh.pydata.org/en/latest/docs/user_guide/webgl.html.
Further reading about Bokeh performance issues with a lot of plots: https://github.com/bokeh/bokeh/issues/6294.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 20 '18 at 8:32









JasperJasper

1846




1846












  • hi, i tried this, the output is that not all graphs are being plotted, and no change in time is seen
    – Sam Shaw
    Nov 20 '18 at 11:39


















  • hi, i tried this, the output is that not all graphs are being plotted, and no change in time is seen
    – Sam Shaw
    Nov 20 '18 at 11:39
















hi, i tried this, the output is that not all graphs are being plotted, and no change in time is seen
– Sam Shaw
Nov 20 '18 at 11:39




hi, i tried this, the output is that not all graphs are being plotted, and no change in time is seen
– Sam Shaw
Nov 20 '18 at 11:39


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53380632%2fhow-can-i-speed-up-the-page-load-of-plots-created-in-bokeh%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

How to fix TextFormField cause rebuild widget in Flutter

in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith