davidsjoberg / ggsankey

Make sankey, alluvial and sankey bump plots in ggplot
Other
268 stars 32 forks source link

Labels always get misaligned #30

Open gluijk opened 1 year ago

gluijk commented 1 year ago

Labels always get misaligned. They don't seem to follow any logical rule. Using ggsankey on a W10 laptop with R version 4.2.1. Output was generated with pdf() since there is no proper antialiasing in the png() output (not an issue of ggsankey but of the OS), and some labels get cropped for being so far from the diagram. The package is excellent however! ggsankey

davidsjoberg commented 1 year ago

Hi! Can you provide the code and data for the graph?

Looks like you maybe be using hjust instead of nudge_x. But that’s just a guess!

gluijk commented 1 year ago

Hi David, thanks for your prompt response. Your guess is totally correct. As a rookie I used an example from: https://rpubs.com/techanswers88/sankey-with-own-data-in-ggplot and for some reason it uses:

pl <- pl +geom_sankey_label(size = 3, color = "black", fill= "white", hjust = -0.5)

I then tried:

Will investigate what nudge_x is about.

Thanks!

gluijk commented 1 year ago

Hi David, you already solved the question on GitHub. I have two more questions:

For instance: this dataframe Before      After G1    G2 G1    G3 G2    G1 G1    G2 G2    G2 G3    G1

Can be defined with a Before/Afer matrix so that all repetated transitions (like G1 -> G2) don't need to be repeated, just counted:

[ [0 2 1] [1 1 0] [1 0 0] ]

This can save tons of space and processing when the equivalent dataframe has thousand of rows.

I'm applying a workaround to compensate for the absence of antialiasing in the Windows output by outputting to PDF and then converting to PNG. The quality is superb!

Best regards


De: David Sjoberg @.> Enviado: jueves, 24 de noviembre de 2022 20:04 Para: davidsjoberg/ggsankey @.> Cc: Guillermo Luijk @.>; Author @.> Asunto: Re: [davidsjoberg/ggsankey] Labels always get misaligned (Issue #30)

Can you provide the code and data for the indie?

— Reply to this email directly, view it on GitHubhttps://github.com/davidsjoberg/ggsankey/issues/30#issuecomment-1326779474, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AK5GWJLAAHNL43P7HZ73J5LWJ635BANCNFSM6AAAAAASKVNPAQ. You are receiving this because you authored the thread.Message ID: @.***>