Hi, I would like to find a working simple example (3 lines I guess) to get html code of a snippet by doing something like this :
import pandas as pd
from bokeh.charts import *
from bokeh.plotting import *
from bokeh.embed import autoload_static
from bokeh.resources import CDN
df = pd.DataFrame(np.random.randn(100, 4), columns=list(‘ABCD’))
name = ‘My plot’
hist = Histogram(df, bins=50)
hist.title(“Histograms”).ylabel(“Random”).legend(True).width(400).height(350)
html = file_html(******, CDN, name)
What must I put instead of ******? I tried hist, curplot, other stuff, nothing works. I don’t know how to retrieve a plot object from a chart object.
Thanks guys for this great module, definetely the most exciting stuff for stats.
Here you have an example: https://github.com/ContinuumIO/bokeh/blob/0.6.0/examples/charts/histograms.py
where you are outputting to an html file.
If you are trying to embed a chart try something like this:
from bokeh.resources import CDN
from bokeh.embed import file_html
import numpy as np
we build some distributions and load them into a dict
mu, sigma = 0, 0.5
normal = np.random.normal(mu, sigma, 1000)
lognormal = np.random.lognormal(mu, sigma, 1000)
distributions = dict(normal=normal, lognormal=lognormal)
then we create a pandas df from the dict
import pandas as pd
df = pd.DataFrame(distributions)
and finally we drop the df into out Histogram chart
from bokeh.charts import Histogram
hist = Histogram(df, bins=50, filename=“histograms.html”)
hist.title(“Histograms”).ylabel(“frequency”).legend(True).width(400).height(350).show()
html = file_html(hist.chart.plot, CDN, “my plot”)
with open(“my_embedded_chart”, “w”) as f:
f.write(html)
Hope it helps!!
Cheers.
···
On Fri, Sep 19, 2014 at 9:51 AM, [email protected] wrote:
Hi, I would like to find a working simple example (3 lines I guess) to get html code of a snippet by doing something like this :
import pandas as pd
from bokeh.charts import *
from bokeh.plotting import *
from bokeh.embed import autoload_static
from bokeh.resources import CDN
df = pd.DataFrame(np.random.randn(100, 4), columns=list(‘ABCD’))
name = ‘My plot’
hist = Histogram(df, bins=50)
hist.title(“Histograms”).ylabel(“Random”).legend(True).width(400).height(350)
html = file_html(******, CDN, name)
What must I put instead of ******? I tried hist, curplot, other stuff, nothing works. I don’t know how to retrieve a plot object from a chart object.
Thanks guys for this great module, definetely the most exciting stuff for stats.
–
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/fb824425-0863-4e1e-9d82-453c74517e1f%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.