[R] how to change the y-axis to logarithmic in a barplot ggplot

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Mon Jul 17 05:43:56 CEST 2023


On Sun, 16 Jul 2023 21:51:10 +0000 (UTC)
Maria Lathouri via R-help <r-help using r-project.org> wrote:

> As you can see, the values range from 0 to 400. I want it to plot it
> in bars; when I am plotting it as you can imagine the values near
> zero don't show at all.

A logarithmic scale won't work when the range of numbers to display
includes 0. It would have worked if it was some small non-zero
quantity, but an actual zero is infinitely far down; it won't fit.

There is a number of transformations described in
help(scale_y_continuous). You may find trans="pseudo_log" or
trans="sqrt" useful.

help(geom_bar) recommends geom_col() instead of geom_bar() to represent
values (not counts of occurrences).

We could help you more efficiently if you clarified the relationship
between your data (with columns `ID`, `values`, `databases`) and your
code (which mentions `Temp`, `mean`, `Glass`).

-- 
Best regards,
Ivan



More information about the R-help mailing list