Histogram with Logarithmic Scale and custom breaks

后端 未结 7 1878
谎友^
谎友^ 2020-11-27 16:33

I\'m trying to generate a histogram in R with a logarithmic scale for y. Currently I do:

hist(mydata$V3, breaks=c(0,1,2,3,4,5,25))

This giv

7条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-27 16:52

    Run the hist() function without making a graph, log-transform the counts, and then draw the figure.

    hist.data = hist(my.data, plot=F)
    hist.data$counts = log(hist.data$counts, 2)
    plot(hist.data)
    

    It should look just like the regular histogram, but the y-axis will be log2 Frequency.

提交回复
热议问题