altair icon indicating copy to clipboard operation
altair copied to clipboard

text position and repel on map

Open sbonaretti opened this issue 5 years ago • 18 comments

Hi,

Thanks for developing Altair! Finally a great tool for visualization using the grammar of graphics in python! I am really having a lot of fun with it!

I am visualizing a map using mark_geoshape. I am adding points to the map using mark_point, and corresponding labeling text using mark_text. I have two issues:

  1. The text is not always close to the corresponding point. I use x = "longitude:Q", y = "latitude:Q" both in mark_point and mark_text. As an example, see the distance between the green dot and the green text in the figure attached;
  2. Texts often overlap - see the pink and brown texts in the figure attached. Is there any function similar to ggrepel in ggplot?

Thank you very much again for such a great tool! Serena

example

sbonaretti avatar Oct 15 '19 16:10 sbonaretti

No, I'm not aware of any functionality to automatically prevent text overlap. It would be worth a feature request in Vega-Lite.

jakevdp avatar Oct 15 '19 16:10 jakevdp

@domoritz I think in theory this would be addressed by https://github.com/vega/vega-label, right? Are there plans to just integrate that work into the core vega story?

davidanthoff avatar Oct 15 '19 19:10 davidanthoff

Yes and yes. We are working on getting it into Vega and then Vega-Lite. I can't promise a release date yet, though.

domoritz avatar Oct 15 '19 20:10 domoritz

Looking forward!!!

sbonaretti avatar Oct 16 '19 08:10 sbonaretti

@chanwutk

domoritz avatar Oct 16 '19 15:10 domoritz

Yes, we are working on getting Vega-Label shipped in Vega. The plan is, then, to add the feature to Vega-Lite. :)

chanwutk avatar Oct 17 '19 04:10 chanwutk

This feature was implemented? I have a similar problem on my plots. image

guilhermeprokisch avatar Apr 22 '20 18:04 guilhermeprokisch

No, it has not been implemented yet as far as I am aware.

jakevdp avatar Apr 22 '20 20:04 jakevdp

It has been implemented and we are in the process of releasing the feature in Vega. The code is already in master at https://github.com/vega/vega/tree/master/packages/vega-label. Once we have support in Vega, we can support it in Vega-Lite as well. I can't promise a release date yet but it's coming. Thanks for your patience. It's a big feature to add with a lot of moving parts.

domoritz avatar Apr 22 '20 21:04 domoritz

Ok! Thank you for the reply :)

guilhermeprokisch avatar Apr 23 '20 14:04 guilhermeprokisch

That's a great piece of news! Thanks and looking forward!

sbonaretti avatar Apr 23 '20 14:04 sbonaretti

@jakevdp It looks like vega implemented a label transform in version 5.16. Is there a way to pass transform data that hasn't officially been implemented in altair yet?

https://vega.github.io/vega/docs/transforms/label/

Thanks!

danhamill avatar Feb 01 '21 20:02 danhamill

@chanwutk is working on bringing labeling to Vega-Lite at which point we can add it to Altair as well.

domoritz avatar Feb 01 '21 20:02 domoritz

Hello@jakevdp, Any update on how to prevent the text overlap. Thank you very much in advance.

arjunkumarp9 avatar May 21 '21 05:05 arjunkumarp9

@arjunkumarp9 This was recently merged into Vega-Lite and will be in a future version of Altair.

joelostblom avatar May 21 '21 05:05 joelostblom

@joelostblom could you please share some example to avoid the overlapping labels. Thank you very much in advance.

arjunkumarp9 avatar May 24 '21 08:05 arjunkumarp9

@arjunkumarp9 There are some VegaLite examples in the PR I linked above. As I mentioned, this feature is not available yet for Altair.

joelostblom avatar May 24 '21 20:05 joelostblom

Note that we reverted the pull request to make sure the API is the best it can be and to make sure the docs are up to date as well. Please follow https://github.com/vega/vega-lite/pull/7378.

domoritz avatar May 24 '21 20:05 domoritz

Closing this as it is an upstream issue and there is nothing to do on the Altair side of things. When https://github.com/vega/vega-lite/pull/7378 is merged, this will be in a following altair release

joelostblom avatar Mar 02 '23 01:03 joelostblom