how to stretch or compress scale / scale_*_trans and label at value 0

I have a some observations with values strongly concentrated at the lower end and only a few (here one) at the higher end. Plotting them with a 'normal' scale_*_continous shows all values but basically makes the concentrated values at the lower end indistinguishable; they become just a lump of points (even with geom_jitter).

I tried to rectify this by applying a log transformation to my values (trans="log10), but this means that the label for the value 0 is not visible (since -Inf). Hence, I was wondering whether there is any other means to stretch / compress the axis/scale to show all lower as well as higher values and keep the 0 axis label.

library(tidyverse)

x <- structure(list(value = c(0.839198091103487, 0.0410272707196604, 
                         0.0168698190749608, 0.0147153083374179, 0.00782626025412454, 
                         0.00782626025412454, 0.00664127934847595, 0.00553709259548522, 
                         0.00549938865757822, 0.00458910787096635, 0.00441136073511906, 
                         0.00324253866000205, 0.00295706598727761, 0.0026823658682409, 
                         0.00255848150083218, 0.00252616383976904, 0.00225146372073232, 
                         0.00197137732485174, 0.00155663400787474, 0.00155663400787474, 
                         0.00128193388883802, 0.00107725536877144, 0.00107186909192759, 
                         0.00105571026139602, 0.00103955143086444, 0.000888735679236441, 
                         0.000807941526578583, 0.000802555249734726, 0.000748692481296154, 
                         0.000727147373920725, 0.000614035560199723, 0.000597876729668152, 
                         0.000517082577010293, 0.000511696300166436, 0.000463219808571721, 
                         0.000447060978040149, 0.000430902147508578, 0.000393198209601577, 
                         0.000393198209601577, 0.00038781193275772, 0.000382425655913863, 
                         0.000382425655913863, 0.000377039379070005, 0.000366266825382291, 
                         0.000360880548538434, 0.00032856288747529, 0.000301631503256004, 
                         0.000301631503256004, 0.000296245226412147, 0.000280086395880575, 
                         0.000280086395880575, 0.000274700119036718, 0.000269313842192861, 
                         0.000269313842192861, 0.000258541288505147, 0.000253155011661289, 
                         0.000236996181129718, 0.00023160990428586, 0.000220837350598146, 
                         0.000210064796910432, 0.000204678520066574, 0.000177747135847288, 
                         0.000172360859003431, 0.000172360859003431, 0.000166974582159574, 
                         0.000161588305315717, 0.000161588305315717, 0.000156202028471859, 
                         0.000145429474784145, 0.000145429474784145, 0.000140043197940288, 
                         0.000134656921096431, 0.000129270644252573, 0.000129270644252573, 
                         0.000129270644252573, 0.000123884367408716, 0.000123884367408716, 
                         0.000118498090564859, 0.000113111813721002, 0.000102339260033287, 
                         9.695298318943e-05, 9.695298318943e-05, 9.695298318943e-05, 9.695298318943e-05, 
                         9.15667063455728e-05, 9.15667063455728e-05, 9.15667063455728e-05, 
                         8.07941526578583e-05, 8.07941526578583e-05, 8.07941526578583e-05, 
                         7.54078758140011e-05, 7.00215989701439e-05, 7.00215989701439e-05, 
                         7.00215989701439e-05, 7.00215989701439e-05, 6.46353221262866e-05, 
                         6.46353221262866e-05, 4.30902147508578e-05, 4.30902147508578e-05, 
                         3.23176610631433e-05)), row.names = c(NA, -100L), class = c("tbl_df", 
                                                                                     "tbl", "data.frame"))

x %>% 
ggplot()+
  geom_point(aes(y=1,
             x=value),
             pos=position_jitter(width=0, height=0.2, seed=2))+
  scale_x_continuous()



x %>% 
  ggplot()+
  geom_point(aes(y=1,
                 x=value),
             pos=position_jitter(width=0, height=0.2, seed=2))+
    scale_x_continuous(trans="log10",
                     breaks=seq(0, 1, .1))

Created on 2019-11-04 by the reprex package (v0.3.0)

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