New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for tick formatters in bokeh #728

Merged
merged 4 commits into from Jun 27, 2016

Conversation

Projects
None yet
4 participants
@philippjfr
Member

philippjfr commented Jun 22, 2016

As the title says this adds support for supplying arbitrary Python functions as tick formatters for the axes. A simple example is a formatter that displays seconds as minutes.

def formatter(seconds):
    m, s = divmod(seconds, 60)
    s = ('%d' % s) if s > 9 else ('0%s' % s)
    return "%d:%s" % (m, s)

hv.Curve(np.random.rand(300)).redim(x=dict(value_format=formatter, unit='min'))

image

Note that this depends on flexx being installed because compiling the python function to JS requires pyscript. Currently it will warn if flexx can't be imported or the function cannot be compiled.

@canavandl

This comment has been minimized.

canavandl commented Jun 22, 2016

Conversely - it supports writing the function in JS or Coffeescript too (without flexx).

@philippjfr

This comment has been minimized.

Member

philippjfr commented Jun 22, 2016

That's true although I'm not sure how or even if we should expose that in HoloViews. The benefit of supplying a Python function is that it should work for both bokeh and matplotlib and will show up correctly in sliders and titles.

@jbednar

This comment has been minimized.

Member

jbednar commented Jun 22, 2016

Looks good to me! Not exposing the JS options sounds appropriate; we don't normally expose anything JS in HoloViews, but Bokeh does it throughout, so it's fine that we make a different choice. Happy to have this merged.

@jlstevens

This comment has been minimized.

Member

jlstevens commented Jun 22, 2016

The flexx dependency looks fine to me as it is a bokeh dependency not a holoviews dependency.

The only thing I would like to check before merging is whether this same interface could be used for the matplotlib backend? Having one function to support two backends would be far better than having to keep switching function (even with redim now available).

@philippjfr

This comment has been minimized.

Member

philippjfr commented Jun 27, 2016

Just added a small change so that a single argument function is supported in matplotlib. We now consistently support single argument functions everywhere and you can also supply a function with an optional second argument, which will be passed the matplotlib pos argument. It's worth noting that matplotlib and bokeh will likely never be consistent here because the pos argument depends on the zoom level and is therefore pretty much useless in bokeh. Ready to review and merge.

@jlstevens

This comment has been minimized.

Member

jlstevens commented Jun 27, 2016

Ok, I reviewed it earlier and it looked fine except for that one issue. Merging.

@jlstevens jlstevens merged commit 8a4a34f into master Jun 27, 2016

4 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.08%) to 69.788%
Details
s3-reference-data-cache Test data is cached.
Details

@jlstevens jlstevens deleted the bokeh_tickformatter branch Jul 12, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment