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

symbols in legend and plot do not match #388

Open
bernstei opened this issue Nov 6, 2024 · 9 comments
Open

symbols in legend and plot do not match #388

bernstei opened this issue Nov 6, 2024 · 9 comments
Labels
component-map Issues related to the map component

Comments

@bernstei
Copy link
Collaborator

bernstei commented Nov 6, 2024

If the symbol comes from a categorical property and the number of categories reaches 6, the symbols in the legend and plot do not match (see 2H_ABp in attachment, circle in legend, triangle in PCA plot)

Image

@Luthaf Luthaf added bug Something isn't working component-map Issues related to the map component and removed bug Something isn't working labels Nov 7, 2024
@bernstei
Copy link
Collaborator Author

The current (pypi) jupyter interface shows the same behavior, but also gives the message "6 symbols are required, but we only have 5. Some symbols will be repeated". Perhaps that's a clue as to where things are going wrong. Note that the screen shot above is from a local web interface of what was, at the time, the latest main branch repo.

@bernstei
Copy link
Collaborator Author

I just updated to the wheel built for the PR mentioned in #393, and it still has the same issue of the legend symbol repeating, but the jupyter show does not have the error message about > 5 symbols. I'll try to take a look at the innards soon.

@bernstei
Copy link
Collaborator Author

A hint - when I do 2D map the legend is correct. Is it possible that the legend always uses the equivalent of a 2D map, while the actual map does things somewhat differently depending on whether it's really 2D or 3D? And there's something broken in the mapping between the two?

@bernstei
Copy link
Collaborator Author

When I use a 2D map, it goes through the code in map.ts once

symbol: this._is3D() ? get3DSymbol(s) : s,
, and I see that it gets 0..5 for the marker symbols. When I do a 3D map it apparently goes through that code twice, first getting 0...5 (i.e. with _is3D false?) and then 'circle', 'square', ... 'triangle_up' (_is3D true?). I'm not sure where to follow this next, but I may try more in the next few days.

@bernstei
Copy link
Collaborator Author

Another but of information is that when I have 7 types, both 6 and 7 show up as circles in the legend, which is also the shape that shows up when my attempts at debugging lead to returning something invalid from get3DSymbol. So it's definitely not just wrapping the index.

@bernstei
Copy link
Collaborator Author

If I change the order of the markers, it refuses to display any other than circle, square, diamond, cross, plus, x. Every other symbol I've tested so far just doesn't work (shows up as a circle) when it's drawing the legend. It must be doing something different about it than the main map.

@bernstei
Copy link
Collaborator Author

I strongly suspect a plotly bug.

@bernstei
Copy link
Collaborator Author

Aha - a workaround. If I make the legend trace have type : 'scattergl' even though the main map is 3D and therefore has type scatter3d, then it works. I suppose that'll only give correct markers if the list of 3D and 2D markers is the same.

@ceriottm
Copy link
Contributor

Uuuh! It might be that it goes look for symbols in the scattergl list rather than scatter3d! This is very useful, thanks @bernstei
I really think we should make sure that 2D and 3D symbols match. Since we're monkey-patching plotly to create the list of symbols used in 3D, this should not be too bad, basically matching the names and symbols of all the 2D ones that differ by the shape (and do not distinguish between full, empty and crossed given we also want to be able to use color).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component-map Issues related to the map component
Projects
None yet
Development

No branches or pull requests

3 participants