- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
所以我要制作一个条形图,并且由于数据范围的原因,y 轴的对数图是有保证的。所以问题是我的值为 0.5,在 log10 中为 -0.3。由于条形变为负数,用于放置标签的条形的“顶部”实际上是“底部”,因此我的文本标签“刚好在”底部,这意味着在条形的中间。我想我可能不是第一个遇到这个问题的人,但搜索相关修复程序并没有帮助。最值得注意的是,我尝试使用闪避,但这并没有改变栏的“顶部”实际上是“底部”。
所以两个问题:
.
alpha=c('A','B','C','D')
value=c(0.5,10,40,1100)
table<-as.data.frame(alpha)
table<-cbind(table, value)
library(ggplot2)
graph <- ggplot(table, aes(x=alpha)) +
geom_bar(stat="identity",aes(y=value),width=0.5) +
geom_text(aes(y=value,label=value),vjust=-0.5) +
scale_y_continuous(trans="log10",limits=c(0.5,1400))
graph + theme_classic()
最佳答案
修改数据标签的y
坐标的小技巧(使用ifelse()
将y
的值设置为 1
如果值小于一)。至于轴,只需隐藏 X 轴(将其设置为 element_blank()
)并绘制一条新的水平线:
graph <- ggplot(table, aes(x=alpha)) +
geom_bar(stat="identity",aes(y=value),width=0.5) +
# Modify the placing of the label using 'ifelse()':
geom_text(aes(y=ifelse(value < 1, 1, value),label=value),vjust=-0.5) +
scale_y_continuous(trans="log10",limits=c(0.5,1400)) +
theme_classic() +
# Hide the X axis:
theme(axis.line.x = element_blank()) +
# Draw the new axis
geom_hline()
print(graph)
输出:
关于r - R : barchart with log scale label misplacement 中的 ggplot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31994951/
我正在尝试在 View 中同时使用 scalegesture 监听器和 gesturelistener。如果比例为 1,则一切正常,但如果将比例设置为其他值,图像会跳到一个新位置,然后平滑缩放。 我的
我在使用 Canvas 和 canvas.scale(Scale, Scale) 时遇到图像质量问题;它们看起来完全像下面这样: android:运行时调整大小的图像质量 我相信我已经阅读了所有关于调
我有一个使用 svg 过滤器附加阴影的 svg 图形。我需要缩放阴影,但找不到可以执行此操作的过滤器。有谁知道这是否可能?
我正在构建一个逻辑回归分类器。 我从一组 500.000 条记录开始,我只想使用其中的一个样本。 你有什么建议: 1) 缩放总体然后采样2)缩放样本3) 仅缩放样本的 X_TRAIN 分割? 为什么?
我有一个功能,我用它在鼠标进入时放大图片并在鼠标离开时返回到正常大小。问题是,如果我在允许图片返回正常大小之前快速将鼠标移出然后将鼠标移入,那么图片将从鼠标输入时当前的任何大小放大(x2.7) (并且
可以在 scale-y-2 中使用 zoomtovalues 吗?我在多个 y 轴上有几个系列,我想将每个 scale-y-n 缩放到特定值,但我不知道如何... 谢谢和问候, 最佳答案 我们在最近的
我正在尝试在 Android 中创建(我认为是)一个相对简单的动画。也就是说,我想让某个 TextView 在单击按钮时缩小到 0 并返回到 1。当我单击该按钮时实际发生的是 TextView 立即缩
我有一个元素需要缩放到父元素的 100%。因为该元素包含基于像素的动画和可以缩放的图像,所以我不能使用百分比。有没有办法使用 css transform scale 来做到这一点? 最佳答案 相对 c
我在 ChartJS 中遇到一个奇怪的错误并且不知道如何修复它,由于这个错误我无法更改比例的任何内容。 我的代码(Sensor.tsx): import { useParams } from "sol
我有一些数据,我正试图通过不断增加的分母来准确和精确地处理这些数据。 请假设分子总是有小数。 我在 docs 中看到divide(BigDecimal divisor) 实际上会减小比例,这看起来很奇
喂, https://jsfiddle.net/jbwq6y87/7/ #box { width: 500px; height: 500px; transition: 0.5s; ov
几个 Tk 小部件也存在于 Ttk 版本中。通常它们具有相同的一般行为,但使用“样式”和“主题”而不是每个实例的外观属性(例如 bg 等)。这很好,因为 Ttk 小部件默认采用操作系统窗口管理器的“标
我尝试转换视频并使用 scale=-1:720 调整其大小,但出现错误“宽度不能被 2 整除”。我解决了这个问题:scale=-2:720。 之间有什么区别 scale=-1:720 和 scale=
我正在尝试重新创建此 codepen变换:我网站上特定页面的缩放转换,但它没有按预期工作 - 正如您在此代码片段中看到的那样(在整页上查看) - 图像覆盖/覆盖不足和不稳定而不是平滑。 /* Part
我有 3 个 Scale 小部件 scale1、scale2 和 scale3。我想使用 scale1 按以下方式控制 scale2 和 scale3 的值: 我不希望 scale2 和 scale3
我目前正在将我的数据分析从 R 转移到 Python。在 R 中缩放数据集时,我会使用 R.scale(),据我所知,它会执行以下操作:(x-mean(x))/sd(x) 为了替换该函数,我尝试使用
从文档中,定义为: 量化 ..a variant of linear scales with a discrete rather than continuous range. The input do
我有一个时基折线图,我正在尝试获取点击坐标处每个刻度的值。 我在 ChartJS 选项中指定的 onClick 函数: onClick: function(event, elementsAtEvent
我见过这样写的代码: ,但我也看到过这样写的代码: initial-scale=1 和 initial-scale=1.0 有区别吗? 最佳答案 没有。 specification描述视口(viewp
给定 y 轴 (s) 上的缩放和 x 轴 (t) 上的平移参数,当目的是最大化曲线叠加(而不是最小化距离)时,如何缩放和对齐两条不重合的曲线? 正如 @DWin 所指出的,这可能会被重新命名为“如何使
我是一名优秀的程序员,十分优秀!