-
Notifications
You must be signed in to change notification settings - Fork 185
Text in facets #514
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
Faceting currently requires that the data of the faceted mark is strictly equal to ( You can workaround this limitation by using the select transform (e.g., Plot.selectFirst) to give the faceted mark the same data as the facet (here, penguins), and then pull out a specific datum for each facet to label. Plot 0.2 will introduce a facet option that will allow you to turn faceting on explicitly for a given mark. However in this case you will still be required to give the faceted mark data that is parallel to the facet data (the same length and order) so that Plot can correctly assign the data to each facet. So, if you only want to label certain points in your scatterplot on each facet, you may need the select transform anyway. If you’d like us to look at your notebook, please publish (unlisted) so we can see. My response above is speculative but hopefully it’s helpful! 😄 |
(Please reply to this issue, even though it’s closed, if you’d like further assistance. If this does turn out to be a bug, I will reopen.) |
I've sent you a suggestion https://observablehq.com/compare/a4546964387cf1c1...87d393e4f6081444 |
To add to Fil’s suggestion, here is an example of using select: Plot.text(data, Plot.selectMaxY({x: "flipper_length_mm", y: "body_mass_g", text: "species"})) |
Hi Mike and Phil, My notebook is unlisted, although it's just an example with dummy annotations 😅 |
You can approach it as filtering: imagine that all of your data points have an associated label, but that most of the time that label is the empty string. See the nyt_display column here: |
Oh, so you pass it through the whole array included in the facet. I hadn't thought about that, thank you! |
When I use facets and include a Text mark, all the items in the array are plotted instead of filtering by the faceting variable. I'm not sure if this is because of how I'm adding the text mark, or if it's a bug. I haven't seen an example of Plot with a facet and annotations that change position and value either.
I've added an example in observablehq.com/d/a4546964387cf1c1
Thanks,
Irene
The text was updated successfully, but these errors were encountered: