Plotly.js: Have nticks be respected when tickmode='array'

Created on 23 Jun 2017  Â·  13Comments  Â·  Source: plotly/plotly.js

Examples for how it should work (using R's plotly package)

Works fine:

library(plotly)
p <- plot_ly(
    width = 800,
    height = 500
  ) %>% layout(
    title = "fixed-ratio axes",
    xaxis = list(
      nticks = 10,
      domain = c(0, 0.45)
    ) )
p

image

Does not yet work:

library(plotly)
p <- plot_ly(
    width = 800,
    height = 500
  ) %>% layout(
    title = "fixed-ratio axes",
    xaxis = list(
      nticks = 10,
      domain = c(0, 0.45),
    tickmode='array'
    ) )
p

image

This feature is specifically important for creating cluster-heatmaps that allow more refined control over the number of ticks (see here)

feature ♥ NEEDS SPON$OR

Most helpful comment

I think the desired output in this instance is for the user to be able to manually specify tick values and labels, but also apply the "auto" tick generating method.

For example, here I am creating a heatmap with categorical labels and automatic ticks by specifying the x co-ordinates, and tick generation works nicely:
https://codepen.io/alanoc/pen/yXPgEp

However, in some cases it is desirable to map categorical scales to numerical scales, in order to present them side-by-side with other plots (and, more importantly, aligned), while maintaining meaningful categorical ticks. For example, heatmaps are commonly presented with dendrograms aligned to rows and columns, in order to show relationships between samples (eg, https://i.stack.imgur.com/1qTWn.png).
To accomplish this, I would commonly specify a numeric axis and tick values, but character tick text. In this case, label overplotting is very common:
https://codepen.io/alanoc/pen/WOXRLE

Perhaps tickvals and ticktext are not the right parameters to be used in this instance, as they do imply the values actually used for ticks; however I do think it would be useful to have this level of control.

All 13 comments

That's the intended behavior. Setting tickmode: 'array' turns off the auto-ticks (where nticks is used).

When you say

Does not yet work:

What do you mean? What is the expected behavior in your mind?

I think the desired output in this instance is for the user to be able to manually specify tick values and labels, but also apply the "auto" tick generating method.

For example, here I am creating a heatmap with categorical labels and automatic ticks by specifying the x co-ordinates, and tick generation works nicely:
https://codepen.io/alanoc/pen/yXPgEp

However, in some cases it is desirable to map categorical scales to numerical scales, in order to present them side-by-side with other plots (and, more importantly, aligned), while maintaining meaningful categorical ticks. For example, heatmaps are commonly presented with dendrograms aligned to rows and columns, in order to show relationships between samples (eg, https://i.stack.imgur.com/1qTWn.png).
To accomplish this, I would commonly specify a numeric axis and tick values, but character tick text. In this case, label overplotting is very common:
https://codepen.io/alanoc/pen/WOXRLE

Perhaps tickvals and ticktext are not the right parameters to be used in this instance, as they do imply the values actually used for ticks; however I do think it would be useful to have this level of control.

This is a problem we are facing right now. I want to be able to add ellipsis to the labels in the X axis, so we use ticktext and tickvals to set the values on the labels. As you can see in the example above by @Alanocallaghan the number of ticks might be a huge amount of data so in those cases, the auto setting is disabled and the labels become unreadable. Perhaps we should be able to handle the number of ticks shown on the graph or let the auto handling for the number of ticks to be available instead of making them mutually exclusive.

@etpinard this issue is #1812

As discussed in https://github.com/plotly/plotly.js/pull/1965#issuecomment-335346105 I think this is a different issue, and might be solved by something like #303 which we could generalize for the tickmode = 'array' case like "iterate through the array and display each tick iff it's more than n pixels away from all the others we've already drawn"

I think that's right @alexcjohnson, thanks for the clarification

Thanks @alexcjohnson for the clarification and for re-opening this.
I'm looking forward for #303 to be resolved, so that you or others could try to leverage it to solve this issue.

Hello @etpinard (and @alexcjohnson),
I see that you wrote in #1946 that it would provide a solution to this issue. I see it is now closed thanks to #1965. Does this mean that this issue is now also resolved? If not, what else should be done in order to address it?

Thanks.

@talgalili this is separate from #1946 and #1965, as mentioned in https://github.com/plotly/plotly.js/issues/1812#issuecomment-335348104

We need to resurrect #303 and incorporate this into it. Unfortunately Plotly folks are extremely busy for the next few months so I don't see this getting addressed in the near future without a community volunteer to spearhead it.

Thanks @alexcjohnson - I've added a comment on #303 and I hope someone could take it upon themselves to add this.

This issue has been tagged with NEEDS SPON$OR

A community PR for this feature would certainly be welcome, but our experience is deeper features like this are difficult to complete without the Plotly maintainers leading the effort.

Sponsorship range: $5k-$10k

What Sponsorship includes:

  • Completion of this feature to the Sponsor's satisfaction, in a manner coherent with the rest of the Plotly.js library and API
  • Tests for this feature
  • Long-term support (continued support of this feature in the latest version of Plotly.js)
  • Documentation at plotly.com/javascript
  • Possibility of integrating this feature with Plotly Graphing Libraries (Python, R, F#, Julia, MATLAB, etc)
  • Possibility of integrating this feature with Dash
  • Feature announcement on community.plotly.com with shout out to Sponsor (or can remain anonymous)
  • Gratification of advancing the world's most downloaded, interactive scientific graphing libraries (>50M downloads across supported languages)

Please include the link to this issue when contacting us to discuss.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

maxwell8888 picture maxwell8888  Â·  3Comments

deecay picture deecay  Â·  3Comments

WG- picture WG-  Â·  3Comments

emanuelsetitinger picture emanuelsetitinger  Â·  3Comments

archmoj picture archmoj  Â·  3Comments