-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Identical axis labels removed in heatmap (need new category mode or axis type) #1516
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
Comments
Thanks for bringing this up! I agree that the expected behavior for Plotly.plot('graph', [{
x: ['a', 'b', 'a'],
y: [1, 2, 3]
}]) generates So I'm thinking maybe we could add a new attribute (e.g. In the meantime, you can make those categories unique by inputting |
Ah, interesting work-around. I didn't realize it would remove the whitespaces when rendering. Thanks! |
I don't think it does remove them... look closely at the positioning, the second Unless this problem generalizes substantially to the point that ticktext/tickvals becomes unworkable, I wouldn't be in favor of making a new axis mode or type for it. Too many strange follow-on effects if data<->position isn't a 1:1 mapping. Like what does it mean if you try to position something else on the axis at |
To solve this issue, we could:
I can't think of another possible |
I still think it’s a bad idea to have an axis that doesn’t map data one-to-one to position. What if you want to tile several heatmaps? What if you want a scatter or bar trace on the same axis? What if you bind a click or hover handler, how will you know on which copy of the item the event really happened? All of these situations would be easy to manage with Perhaps we could consider a mode within the |
I am having the same issue with a bar chart and see this as a major oversight. I just want to print a simple bar chart for a group of clinical measurements. Some animals were measured multiple times and some were not so traces will not work correctly. I should be able to display multiple values with the same x axis label without having 10 white spaces surrounding the 10th measurement for a specific label. As an example my x axis may look like the following Rat, Rat, Rat, Rat, Rat, Chicken, Squirrel, Chicken. Any ideas other than the white space fix above are appreciated. |
@jdepons the method suggested by @cpsievert in #1516 (comment) works better than the white space hack, although it's a little bit tedious. |
Is there any official solution to this? Im generating the x_labels automatically in-app and the whitespace solution is definetely not an option! Any recomendations? |
This is actually severe. The priority to fix this should be highest. |
@SaucePan1 @Dantalion have you tried the One current limitation I see of this approach is that we always show every tick when using |
Just to add another voice to this. I've got a heatmap where I'm showing the results of differential expression experiment with 6 clusters. I'm showing the top 10 and bottom 10 genes for each cluster, so the Y: genes, X: clusters. In many cases, the genes overlap. I'll certainly try the ticktext approach, but I might have 100's of genes, so the ability to automatically choose the tick interval is extremely nice... |
Hey guys! A little late to the party - however we've just run into this exact issue with the stacked-bar-chart. We are trying to display the properties of tools that are used in a process. Of course tools can be used multiple times. Thanks to the solution of @cpsievert it works like a charm! (Thank you very much!). Here's a simple example where I just mixed the example code for stacked-bar-charts with the solution proposed by @cpsievert :
The reason why I'm posting this: Would you kindly consider adding this information to the official documentation? (e.g. here) As this issue shows it's not an uncommon requirement and since there is a practical solution for this it would be great if it was described close to the charts themselves - maybe as an additional example (e.g. "bars with multiple occurrences of x-values"). (Sorry if it's already there and I just missed it!) |
Help! With the latest plotly.js (1.51.3) the tickvals/ticktext solution no longer works. If you look at http://codepen.io/cpsievert/pen/bqKJoe you can see that only one category is shown. This is broken some important functionality for our pipeline. |
@RBVI your tickvals and x/y values need to match up: var dat = [{
"x": [0,1],
"y": [2,3],
"z": [[1,2], [3,4]],
"type": "heatmap"
}];
Plotly.plot(
"graph", dat,
{
"xaxis": {
"ticktext": ["a", "a"], "tickvals": [0, 1]
},
"yaxis": {
"ticktext": ["b", "c"], "tickvals": [2, 3]
}
}
); (don't want to sign up for codepen to save that.) The original version of this solution posted in #1516 (comment) matches by |
This issue has been tagged with 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: $10k-$15k What Sponsorship includes:
Please include the link to this issue when contacting us to discuss. |
If we are going to use a spacer workaround, using zero-width-space[1] would save some space on the screen function pad_unique(arr, pad='\u200b'){
let mem = new Set()
for (let idx = 0; idx < arr.length; idx++) {
let val = arr[idx]
while (mem.has(val)) {
val += pad
}
mem.add(val)
arr[idx] = val
}
return arr
}
// call this on x and y arrays to make them unique
pad_unique(x)
pad_unique(y) demo https://codepen.io/thammegowda/pen/jOGEqrG |
Hi - this issue has been sitting for a while, so as part of our effort to tidy up our public repositories I'm going to close it. If it's still a concern, we'd be grateful if you could open a new issue (with a short reproducible example if appropriate) so that we can add it to our stack. Cheers - @gvwilson |
Consider the following plot (as JSON):
Note how there are identical axis labels in the JSON on the x and y-axis. This leads to an incorrect rendering:

It appears the identical labels get removed automatically.
Additional context here and here.
The text was updated successfully, but these errors were encountered: