Can anyone point me in the right direction for adding a legend to plots based on the ‘rect’ glyph, like http://bokeh.pydata.org/en/latest/docs/gallery/les_mis.html and http://bokeh.pydata.org/en/latest/docs/gallery/unemployment.html ?
I am using the python interface to bokeh and displaying the result in a web browser, if it matters. In my usage, I would like to have a legend indicating the values behind the color scale. Is the legend something that is packages as an object, or does one have to pretty much roll your own code like it were a separate plot?
Thanks in advance,
Hi,
Two things:
- I wanted to make a fairly custom legend which actually lived on the plot (for space constraints).
You can see it here:
https://the-frack-lab.github.io/data/natural-gas/US-long-term/graph.html
and the code here:
http://nbviewer.ipython.org/github/the-frack-lab/data/blob/gh-pages/natural-gas/US-long-term/Long-term%20natural%20gas%20production.ipynb
unfortunately this is using an older version of bokeh, so you can’t just copy and paste that code.
but it’s pretty similar. it will be something like:
fig = figure(title="U.S. natural gas produc …
then
fig.patches(…
fig.text(…
fig.rect(…
I haven’t tested this but hopefully it points you in the right direction.
- In addition, I made a legend for my washmap - but that was in a seperate plot that was then assembled with hplot/vplot.
You can see the final visualization here:
http://washmap-bokeh.herokuapp.com/static_map_tools_linked_tabbed
and some of the code here:
http://nbviewer.ipython.org/github/birdsarah/pycon_2015_bokeh_talk/blob/master/notebooks/Building%20the%20static%20visualization.ipynb
the rest of the code is in that repo e.g.: https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/washmap/water_map.py#L179
Hope this helps,
Bird
···
On Wed, Apr 22, 2015 at 5:00 PM, [email protected] wrote:
Can anyone point me in the right direction for adding a legend to plots based on the ‘rect’ glyph, like http://bokeh.pydata.org/en/latest/docs/gallery/les_mis.html and http://bokeh.pydata.org/en/latest/docs/gallery/unemployment.html ?
I am using the python interface to bokeh and displaying the result in a web browser, if it matters. In my usage, I would like to have a legend indicating the values behind the color scale. Is the legend something that is packages as an object, or does one have to pretty much roll your own code like it were a separate plot?
Thanks in advance,
–
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/41f641b7-89f5-4ed8-b4d2-a6c93997c29b%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.