show 0 in a log scale y axis of plot in R

后端 未结 3 1814
孤城傲影
孤城傲影 2021-01-22 05:25

Because the y values are too small, I need to use a log scale for y axis to show the differences. In the data, some entries do not have any value (0). Is there any way to show \

3条回答
  •  [愿得一人]
    2021-01-22 05:27

    I found myself doing something similar although also completely different. For people who has stumbled here what I did might be of some use perhaps.

    I had the problem that I had very large numbers that I wanted to show on a logarithmic scale but also some zeros. I went with a barplot and used NA for the 0s. It turns out that NA is left as empty space which I think makes sense in this case. I made an example of only 10 numbers but R seems to handle scaling for more values quite good:

    values<-c(100000, 100, 2, 5, NA, NA, 2, 1, NA, 1)
    barplot(values, names=1:length(values), log="y")
    

    illustrative image

提交回复
热议问题