How to replace x- axis values (log scale) with their respective untransformed linear values in base R histogram

Hi, i have a problem with histogram in Rstudio. I have to represent with the funtion "hist" the distribution of several of rainfall observations. Most of them are next to 0 so preferred to create a vector of transformed data (log(x)). So I want to represent the transformed values (log scale) in histogram but with the untransformed linear values in x-axis.
I know that with the function "plot" for scatterplot I can obtain it by adding in the code log="x" but I now want a histogram, not other.

my code:
hist( log_rainfall, xlab = "rainfall [mm/h] in ln", ylab = "",
prob= TRUE, col = "cyan2", axes=FALSE )

Thank you for the help.
Roberta

In order for us to better help you, please share a reproducible example of your problem

1 Like

Sure, sorry.
my simplified code:

place1_lin=c(0.12, 0.37, 0.2, 0.44, 0, 2.3, 1.5)
place1_log=log(place1_lin)
place1_log[place1_log==-Inf]<--2.3
hist( place1_log, xlab = "rainfall [mm/h] in ln", ylab = "",
prob= TRUE, col = "cyan2")

In vector "place1_lin" I have the original values.
In vector "place1_log" I replaced all original values in log scale (I replaced log(0) with log(0.1)=-2,3 in order to avoid "-Inf").

I'd like to obtain in x-axis of the histogram the original values, not the log scale ones.
Thank you.

FFR, reprex is actually a package that helps you run self-contained code, and copies it to your clipboard formatted it with images etc. so you can paste it right in here:

place1_lin=c(0.12, 0.37, 0.2, 0.44, 0, 2.3, 1.5)
place1_log=log(place1_lin)
place1_log[place1_log==-Inf]<--2.3
hist( place1_log, xlab = "rainfall [mm/h] in ln", ylab = "",
      prob= TRUE, col = "cyan2")

Created on 2019-01-04 by the reprex package (v0.2.1.9000)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.