Hi, Have you tried:
scale_y_continuous(trans='log10') HTH, Kimmo ________________________________________ Lähettäjä: Maria Lathouri via R-help <r-help@r-project.org> Lähetetty: maanantai 17. heinäkuuta 2023 23.01.57 Vastaanottaja: Maria Lathouri via R-help; Ivan Krylov Aihe: Re: [R] how to change the y-axis to logarithmic in a barplot ggplot Hi Ivan, yes you are right. I have many values close to zero and if I use log, they are instantly transformed to negative values and then the bars show above. The sqrt trans worked ok but when I used the pseudo_log_trans, it did the work! Many thanks. Kind regards, Maria Στις Δευτέρα 17 Ιουλίου 2023 στις 04:43:59 π.μ. GMT+1, ο χρήστης Ivan Krylov <krylov.r...@gmail.com> έγραψε: On Sun, 16 Jul 2023 21:51:10 +0000 (UTC) Maria Lathouri via R-help <r-help@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 ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.