Friday, June 17, 2016

Bokeh Plots in Blogger





This is a quick post to test if I can add Bokeh plots in my blog.



Here is my plot.


The formatting is a bit off, but it works!

The way I did this was to paste the HTML and Javascript directly in my post as well as set the Options on the right to Interpret typed HTML.
That is, I used script, div = components(plot) to generate what I needed to include and at the top of my post added some text to load BokehJS from CDN. See their website for instructions.

Here is a second attempt, but using an iframe and hosting the HTML file elsewhere:


This is a lot easier to manage so I'll probably stick to using iframes.

For those that don't know, Bokeh is a plotting library in Python (and I think in a few other coding languages as well) that allows for interactive plots in websites. I'll probably be editing this post as I fix things, but for now I wanted to test if this works in Blogger so I can prepare more interesting posts in the future. I may also test using iframes as the scripts to paste can be rather large, even for a simple plot like this one.

3 comments:

  1. Thanks. This is exactly what I was looking for :)

    ReplyDelete
  2. can you show the html? I cant manage the plot controls

    ReplyDelete
    Replies
    1. You can see the HTML of the plot by going to http://dr-rodriguez.github.io/files/iris.html and right-clicking and selecting the option to view the Page Source, or the equivalent in your browser. I pretty much just copied the script and link sections into this post and put the div part with where I wanted the plot to appear. (I tried pasting some HTML here but Blogger won't let me).

      Delete

Note: Only a member of this blog may post a comment.