On May 22, 2018, at 18:57, Adrian Ciconte <adrian.ciconte.td@gmail.com> wrote:
Thanks Bryan,
I have been reading over the documentation and applying the plotting API syntax (based on the documentation you sent) to my problem (which worked perfectly using version 0.12.02) however, when I upgraded to 0.12.16, I get the following error.
Data:
bokeh_bar = df.groupby(["Audience"], as_index=False)["Impressions"].sum()
Index Audience Impressions
0 Core 23725548
1 Homepage 14163811
2 LAL_10% 18277859
3 LAL_3% 14879857
4 Page_1 4406266
Code:
source = ColumnDataSource(data=dict(audience=bokeh_bar["Audience"],
impressions=bokeh_bar["Impressions"],
color=Spectral6))
p = figure(x_range=list(bokeh_bar["Audience"]), plot_height=250, title="Impressions by Audience",
toolbar_location=None, tools="")
p.vbar(x=bokeh_bar["Audience"], top="Impressions", width=0.9, color='color',
legend="Audience", source=source)
p.add_tools(HoverTool(tooltips=[("Audience", "@audience"), ("Impressions", "@impressions")]))
p.xgrid.grid_line_color = None
p.legend.orientation = "horizontal"
p.legend.location = "top_right"
show(p)
Error:
RuntimeError:
Supplying a user-defined data source AND iterable values to glyph methods is
not possibe. Either:
Pass all data directly as literals:
p.circe(x=a_list, y=an_array, ...)
Or, put all data in a ColumnDataSource and pass column names:
source = ColumnDataSource(data=dict(x=a_list, y=an_array))
p.circe(x='x', y='y', source=source, ...)
Am I missing something glaringly obvious? I feel like I've addressed both these errors in my code.
Thanks in advance for your help.
Adrian
On Wednesday, May 23, 2018 at 2:02:32 AM UTC+10, Bryan Van de ven wrote:
Hi,
Don't use bokeh.charts (including Bar) for anything. It was a failed experiment, and was deprcated and subsequently removed entirely last year. It is currently completely unmaintained and unsupported.
Instead, use the well-supported bokeh.plotting API, which has had very significant improvements to make all kinds o bar charts much simpler (the bokeh.plotting API is now more capable than bokeh.charts.Bar ever was):
http://bokeh.pydata.org/en/latest/docs/user_guide/categorical.html
Thanks,
Bryan
> On May 22, 2018, at 08:02, Adrian Ciconte <adrian.c...@gmail.com> wrote:
>
> Hello!
>
> I have the following dataframe:
>
> Date Impressions Link_Clicks
> 2017-05-29 00-00-00 1,492,046 8,093
> 2017-06-05 00-00-00 845,012 4,864
> 2017-06-12 00-00-00 1,167,100 6,897
> 2017-06-19 00-00-00 895,781 4,472
> 2017-06-26 00-00-00 1,037,839 9,518
> 2017-07-03 00-00-00 1,139,060 9,668
> 2017-07-10 00-00-00 1,235,760 9,268
> 2017-07-17 00-00-00 1,200,906 7,989
> 2017-07-24 00-00-00 1,214,534 6,991
> 2017-07-31 00-00-00 1,434,225 7,311
> 2017-08-07 00-00-00 557,393 2,908
>
> I am trying to visualise this using Bokeh which I've managed to do successfully, however when implementing the hover-tool, it returns the number divided specifically by 2. Is this a bug?
>
> Libraries used:
>
> from bokeh.io import output_notebook, show, push_notebook
> from bokeh.io import output_file, show, curdoc
> output_notebook()
> from bokeh.plotting import figure, ColumnDataSource
> from bokeh.models import HoverTool, DatetimeTickFormatter, DataRange1d, CustomJS, Plot, LinearAxis, Grid
> from bokeh.charts import Bar, BoxPlot, Donut, HeatMap, Histogram, Line, Scatter, TimeSeries
>
> My code can be found below:
>
> source = ColumnDataSource(data=dict(
> desc = bar_df.index,
> y = bar_df["Link_Clicks"],
> ))
>
> p = Bar(bar_df, label=bar_df.index, values="Link_Clicks", width=1, source=source, agg='sum',
> line_color="white", plot_width=900, plot_height=400, bar_width=0.9, legend=None, toolbar_location="right")
>
> p.add_tools(HoverTool(tooltips=[("Link_Clicks", "@y{1.11}"),
> ("Date", "@index")]))
>
> p.xaxis.major_label_orientation = 45
>
> show(p)
>
> NOTE: if you try and replicate this, dates for Bokeh can't be in DateTime format; only strings.
> To quickly convert: df["Date"] = df["Date"].apply(lambda x: str(x).replace(':','-'))
>
> When hovering over, you can see this is divided perfectly by 2 which is strange. I have tried multiplying y*2 under ColumnDataSource and within the Hover Tool, but still no luck.
>
> Any ideas?
>
> --
> 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 bokeh+un...@continuum.io.
> To post to this group, send email to bo...@continuum.io.
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/3f680b76-46b0-467f-a5a0-4d172d96b9dd%40continuum.io\.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout\.
--
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 bokeh+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/5c070f25-180e-485e-8b08-3083b096b3f6%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.