I need to plot with ggplot2 package in R a graph with some negative values using an x logarithmic scale.
For example I want to plot these points using an x logarithmi
For this, I find the pseudolog10_trans
transformation from the ggallin
package
to be very helpful, as it can accomodate situations with both positive and negative numbers on a log scale. E.g.
library(ggplot2)
library(ggallin)
x <- c(-1,-10,-100, 1, 10, 100)
y <- c(1,2,3, 1,2,3)
df = data.frame(x = x, y = y)
My_Plot = ggplot(
df,
aes(x=x, y=y)) +
geom_point() +
scale_x_continuous(trans = pseudolog10_trans)
My_Plot