You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Axis labels for "bucket" or "bin" axes: custom function, esp for bucket range labels #69
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
}
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.
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...
+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.
Activity
alexcjohnson commentedon Dec 4, 2015
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 commentedon 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 commentedon Oct 12, 2016
+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 commentedon Oct 13, 2017
Closing in favor of #2086