带log1p转换的annotation_logticks

时间:2018-06-26 01:14:57

标签: r ggplot2 tidyverse

是否有一种方法可以调整annotation_logticks()中的ggplot2以进行log1p转换?

示例:

library("ggplot2")
df <- data.frame(trt = c("a", "b", "c"), outcome = c(5, 10, 30))
p <- ggplot(df, aes(trt, outcome)) + geom_col()

这将产生预期的结果:

p + scale_y_continuous(trans = "log") +
  annotation_logticks(base = exp(1), sides = "l")

enter image description here

这不是(注意两组刻度线不对齐):

p + scale_y_continuous(trans = "log1p") +
  annotation_logticks(base = exp(1), sides = "l")

enter image description here

1 个答案:

答案 0 :(得分:2)

/** * The array in which the elements of the deque are stored. * The capacity of the deque is the length of this array, which is * always a power of two. The array is never allowed to become * full, except transiently within an addX method where it is * resized (see doubleCapacity) immediately upon becoming full, * thus avoiding head and tail wrapping around to equal each * other. We also guarantee that all array cells not holding * deque elements are always null. */ transient Object[] elements; // non-private to simplify nested class access /** * Inserts the specified element at the end of this deque. * * <p>This method is equivalent to {@link #addLast}. * * @param e the element to add * @return {@code true} (as specified by {@link Collection#add}) * @throws NullPointerException if the specified element is null */ public boolean add(E e); /** * Retrieves and removes the head of the queue represented by this deque. * * This method differs from {@link #poll poll} only in that it throws an * exception if this deque is empty. * * <p>This method is equivalent to {@link #removeFirst}. * * @return the head of the queue represented by this deque * @throws NoSuchElementException {@inheritDoc} */ public E remove(); /** * Retrieves, but does not remove, the head of the queue represented by * this deque. This method differs from {@link #peek peek} only in * that it throws an exception if this deque is empty. * * <p>This method is equivalent to {@link #getFirst}. * * @return the head of the queue represented by this deque * @throws NoSuchElementException {@inheritDoc} */ public E element(); 中使用breaks

scale_y_continuous