Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embedding Bokeh plots in wordpress post

I can generate and embed a bokeh plot in a post, but can't get the plot to align left (or center)

Plot generated using autoload_static() as shown here:

import numpy as np
from bokeh.plotting import figure
from bokeh.embed import autoload_static
from bokeh.resources import CDN


x = np.random.uniform(0, 1, 10)
y = np.random.uniform(0, 1, 10)

p = figure(width = 400, height = 400,
       title = 'Sample Figure')

p.circle(x, y, size = 10)

js, tag = autoload_static(model = p, resources = CDN, 
                      script_path = 'mysite/sample.js')

jsfile = open('sample.js', 'w')
jsfile.write(js)
jsfile.close

print(tag)

Then, uploading sample.js to the site, and pasting the tag into the wordpress post editor gives me this:

embedded figure

How can I get the left edge of the figure to align with the left edge of the post?

Edit: Just saw this question

Center embedded Bokeh plot, which I think is the same issue, but it's a bit over my head.

like image 290
bksk1lz Avatar asked Jan 29 '26 22:01

bksk1lz


1 Answers

I am not entirely certain myself but I have a couple ideas you can look into,

1) Check out: https://github.com/bokeh/bokeh/tree/master/examples/embed

2) I know it is possible to write posts in HTML on wordpress if you put the js content with script tags, from what I understand, it should embed the code.

Hope this helps.

like image 183
Dan Temkin Avatar answered Jan 31 '26 23:01

Dan Temkin