jthomasmock / gtExtras

A Collection of Helper Functions for the gt Package.
https://jthomasmock.github.io/gtExtras/
Other
195 stars 27 forks source link

gt_plt_bar truncates small numbers #124

Open lighthouseenergy opened 7 months ago

lighthouseenergy commented 7 months ago

In creating a table with bar plots, gtExtras seems to truncate small values since it puts the values inside the bars.

For example, my_tbl |> gt_plt_bar( column = bcr, color = "#EED31D", scale_type = "number", accuracy = 0.01, text_color = "black" ) |> gt_plt_bar( column = mw_2043, color = "#27AAE1", scale_type = "number", accuracy = 0.01, text_color = "black" )

Generated this: Rplot

While expanding the width of the plot can help to a limited extent, I think it will ultimately be a problem with numbers of greatly varying scales.

Is it possible to specify right justification via passing hjust = 0 to the geom_text() in ggplot?

This would also provide an added benefit of aligning all numbers for easier readability across rows, resulting in something like this (from Excel): image

Thanks!

bhogan-mitre commented 4 months ago

I ran into this today as well. If it's an easier fix, I think it would be very helpful to add the label_width parameter that gt_plt_bar_pct has to the gt_plt_bar function. I'm not sure if that meet's the original need here, but I wanted to mention it here first instead of adding it a separate issue.