- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
下面有一个名为 molten.data
的数据。我有这段代码可以绘制我想要的线条,但我需要更改一条特定线条 (G11F:G11M
) 的粗细,使其看起来比其他线条更粗,或者最好为数据添加形状在那条线上的点。我们怎样才能做到呢?
我有代码:
ggplot(molten.data, aes(variable, value,group= key.related,colour=key.related)) +
geom_line() +
geom_point()
数据:
molten.data<- structure(list(key.related = c("G11F:G11F", "G11F:G11F", "G11F:G11F",
"G11F:G11M", "G11F:G11F", "G11F:G11M", "G11F:AOGC-02-0079", "G11F:G11F",
"G11F:G11M"), variable = structure(c(1L, 2L, 3L, 3L, 4L, 4L,
4L, 5L, 5L), .Label = c("IBS_2_samples", "IBS_4_samples", "IBS_8_samples",
"IBS_16_samples", "IBS_32_samples"), class = "factor"), value = c(0.533,
1.01, 1.11, 0.132, 1.22, 0.353, 0.0658, 1.33, 0.534)), .Names = c("key.related",
"variable", "value"), row.names = c(1L, 82L, 163L, 168L, 244L,
249L, 260L, 325L, 330L), class = "data.frame")
最佳答案
您可以设置一列来注明是否应突出显示观察结果,并将其映射到大小、形状、线型等。
您可以使用ifelse
来做到这一点:
library(tidyverse)
molten.data %>%
mutate(hilite = ifelse(key.related == "G11F:G11M", 2, 1))
#> key.related variable value hilite
#> 1 G11F:G11F IBS_2_samples 0.5330 1
#> 2 G11F:G11F IBS_4_samples 1.0100 1
#> 3 G11F:G11F IBS_8_samples 1.1100 1
#> 4 G11F:G11M IBS_8_samples 0.1320 2
#> 5 G11F:G11F IBS_16_samples 1.2200 1
#> 6 G11F:G11M IBS_16_samples 0.3530 2
#> 7 G11F:AOGC-02-0079 IBS_16_samples 0.0658 1
#> 8 G11F:G11F IBS_32_samples 1.3300 1
#> 9 G11F:G11M IBS_32_samples 0.5340 2
我的偏好是根据因素来进行。 forcats::fct_other
允许您选择要保留的级别,并将其他所有内容标记为“其他”。想象一下,您有几个键想要保留其原始名称,还有很多键想要归入“其他”类别 - 随着数据变得更加复杂,它变得非常有用。
然后我将其输入到 ggplot
中,使用 hilite
来指定突出显示。一种方法是尺寸;您可以调整尺寸以使其更加引人注目,或者获得任何合适的尺寸:
molten.data %>%
mutate(hilite = as.factor(key.related) %>% fct_other(keep = c("G11F:G11M"), other_level = "Other keys")) %>%
ggplot(aes(x = variable, y = value, color = key.related, group = key.related, size = hilite)) +
geom_line() +
geom_point(size = 2) +
scale_size_manual(values = c("G11F:G11M" = 1.5, "Other keys" = 0.5), guide = F)
或者保持尺寸统一但改变形状。在这里,我设置了形状值,以便非突出显示的点获得正常的圆形点,突出显示的点获得三角形。
molten.data %>%
mutate(hilite = as.factor(key.related) %>% fct_other(keep = c("G11F:G11M"), other_level = "Other keys")) %>%
ggplot(aes(x = variable, y = value, color = key.related, group = key.related)) +
geom_line() +
geom_point(aes(shape = hilite), size = 2) +
scale_shape_manual(values = c("G11F:G11M" = 17, "Other keys" = 16), guide = F)
由reprex package于2018年7月1日创建(v0.2.0)。
关于r - 如何更改特定线条的粗细和/或在多线图中添加形状?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51119948/
我有一个格式良好的单元格范围,具有不同的边框线粗细(其中一些是中等厚度,其中一些是薄的,没有特定的图案)。我想运行一个将边框颜色更改为灰色的宏,但每次执行此操作时,它都会自动将所有边框粗细更改为 xl
我可以使用百分比使我的图像/div 具有响应性。 如何使字体大小响应不同的屏幕大小? 最佳答案 我最近偶然发现了这个问题,并为此编写了一个适合我需要的解决方案。也许您会发现您也可以将它合并到您的 CS
在 iOS 8 中,为了获得 Helvetica Neue 的细变体,以下代码可以工作 UIFont.systemFontOfSize(50, weight: UIFontWeightThin) 在
我想将 matplotlib 绘图中使用的默认字体更改为 Windows 下的 Segoe UI。我可以通过像这样改变 rcParams 来做到这一点 import matplotlib matplo
我想知道是否有人知道基于 Bresenham 的线算法或任何类似算法绘制具有特定粗细的线的任何算法。 再想一想,我一直在想,对于每个 setPixel(x,y) 我只是画一个圆圈,例如: filled
我正在尝试自定义我已经拥有的用于选择 Google 字体和更新预览 DIV 的功能之一,但是我还想添加“字体大小”、“字体粗细”、“字母间距”等,但是此功能仅在您单击“主字体选择器”组合框时才有效,我
我正在使用 RaphaelJS 在 IE8 中调试一些性能问题。我们正在 raphael 中从大约 1000 个元素和文本节点构建图形,特别是一个图形在渲染时给我们带来了问题。在 IE9 中,根据机器
我是一名优秀的程序员,十分优秀!