Skip to content
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

Axis labels for "bucket" or "bin" axes: custom function, esp for bucket range labels #69

Closed
mewalig opened this issue Dec 3, 2015 · 4 comments

Comments

@mewalig
Copy link

mewalig commented Dec 3, 2015

Hello,

Could you please add a feature to support customized formulaic axis labels? I looked around the documentation but didn't find support for this-- if it's there and I missed it, please let me know!

The main use I can think of is for graphs that create or require data "buckets" or "bins" such as histogram or surface graphs. Currently, for these, axis labels only show a single value (e.g. "72"), so the reader cannot tell whether that value is the low end or the middle or the high end of the bucket, or whether an exact match with a bucket boundary would be deemed to be included in the lower or the higher bucket.

As an example, see the 2013 NHL Player Height histogram at http://help.plot.ly/make-a-histogram/. It is not clear from this whether the the bucket labeled "72" means "71-72", "71.5-72.5", or "72-73". Hovering over suggested that it is 71.5-72.5, but it still is not clear whether a value of "71.5" would be included in the bucket labeled "71" or "72".

A generalized, flexible and intuitive approach to solving this problem would be to support a custom function for generating the label value, where the input to the function would be the label value that is currently being used (e.g. "72"). So the function could be:

function NHL_age_label(age) {
  return String(age - .5) + " < x <= " + String(age + .5)
  // not sure if should be (a <= x < b) instead, but you get the idea
}
@alexcjohnson
Copy link
Collaborator

You can do this statically using ticktext

I don't want to include javascript in the plot definition - makes it either not portable, or a security risk.

What I'd prefer to do is make smarter hover text for histograms. So the axis labels (which may or may not correspond to bins) can stay as they are, unless you use ticktext, but the hover text will be smarter - perhaps even showing the actual range of data aggregated in the bin, which would provide more useful information than just what the precise edges of the bin are.

@mewalig
Copy link
Author

mewalig commented Dec 7, 2015

thanks, will look into ticktext. in case it is helpful to know, in my experience documenting ranges for financial services transactions, being able to show the ranges in the form of "x.00 - y.99" (to however many zeros and nines the creator wants/needs) is the most useful, because it shows not only the exact range, but also conveys the rounding approach that was used (e.g. "first round to two decimal places, then put in the corresponding bin"). I'm not saying that is what this library should default to, but it would be great if it was able to support a way to achieve that. Maybe ticktext already does-- I will find out now...

@skimbels
Copy link

+1, this would be a great improvement for histograms. The axis labels can remain as they are, but the label on each bin should display the range, rather than a single value.

@alexcjohnson
Copy link
Collaborator

Closing in favor of #2086

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants