问题标签 [direct-labels]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
108 浏览

r - 如何使用 direct.label 在绘图上标记前几个点并创建不重叠的标签

如何轻松创建文本不重叠的图?

另外,我如何创建一个只标记前几个点的图?如下图所示,我想始终标记情节的左下角

如何在 R 中创建下面的图 在此处输入图像描述

0 投票
2 回答
3968 浏览

r - Directlabels 包——标签不适合绘图区域

我想用 ggplot 探索 directlabels 包。我正在尝试在简单折线图的端点处绘制标签;但是,标签被绘图面板剪裁。(我打算在一个图中绘制大约 10 个金融时间序列,我认为直接标签将是最好的解决方案。)

我想可能会有另一种解决方案使用annotate或其他一些几何图形。但我想使用直接标签解决问题。请参阅下面的代码和图像。谢谢。

带有结束标签的折线图

在数据可视化原则上,我想避免扩展 x 轴以使标签适合——这意味着有没有数据的数据空间。相反,我希望标签向图表框/面板之外的空白区域延伸(如果有意义的话)。

0 投票
1 回答
5713 浏览

r - R将图例和直接标签添加到ggplot2等高线图

我有一个栅格地图,我想使用 ggplot2 使用连续比例和标记的等值线绘制它。

为此,我正在使用 directlabels 包,并且接近于获得我想要的东西,但我无法在同一张地图上同时获得图例和标记的等值线

以下代码重现了我的问题:

情节 1 在此处输入图像描述

情节 2 在此处输入图像描述

情节 3 在此处输入图像描述

我想在背景中有彩色光栅,侧面有颜色图例,顶部有标记的等值线。有没有办法做到这一点?

还有一种方法可以将标签放置在等值线的中间而不是底部或顶部?

提前致谢

巴勃罗

0 投票
1 回答
678 浏览

r - 用 direct.labels 标记两个轮廓

我正在尝试比较两个标量字段,并希望使用等值线将它们绘制在同一个图中,使用直接标签标记它们的值。问题是,我不能在同一个情节中使用两个直接标签。

例子:

只有一个变量被标记。

另一种方式:

有什么解决办法吗?

谢谢!

0 投票
2 回答
493 浏览

r - directlabels: using different positioning methods for different panels in the same plot

I have a two-panel lattice lineplot. I want to use the directlabels package to automatically label the lines in each plot. But I want to use a different positioning method for each plot. Specifically, I want to use the first.bumpup method for the first panel, and the last.bumpup method for the second panel. Here is a minimal example:

This code produces a plot in which labels appear on the left-hand side of each panel:

figure produced by example code

I want labels on the left-hand side of the left-hand panel (as in this example), but on the right-hand side of the right-hand panel. What is the simplest way to produce that sort of figure?

I've checked the advanced examples in the directlabels documentation, and they make me think that it may be possible to use different methods for different panels by creating a custom positioning method or a custom panel. But I cannot quite see how to do it.

0 投票
2 回答
6966 浏览

r - 如何将百分比和分数添加到 ggplot geom_text 标签?

我有一个数据集,我有兴趣在其中查看测试分数和经历事件的人的百分比:

我可以用图表上的百分比来绘制它,如下所示:

在此处输入图像描述

或者我可以用这样的分数来绘制它:

在此处输入图像描述

但我想让他们两个并排。这不起作用:

我收到此错误:

解析错误(文本 = as.character(实验室))::1:3:意外输入 1:30%frac(263,877)^

谢谢您的帮助!

0 投票
1 回答
202 浏览

r - How to plot labels to corresponding line (on this plot) in ggplot2?

I have this data:

I plot each colum in this way:

the result is:

enter image description here

Now, i would like to not use the legend, but labels on plot line, one label for corresponding line. I tried with this code:

from this link: https://learnr.wordpress.com/2010/01/03/directlabels-adding-direct-labels-to-ggplot2-and-lattice-plots/

but r response is:

Do you know other possibility to plot labels on line plot, like (for example) in this way? enter image description here

0 投票
1 回答
834 浏览

r - 在计算的 stat_smooth 线上添加标签 ggplot geom_dl

我一直在尝试将标签直接添加到我的线性模型散点图中,但有些困难。我已经阅读了这些文章(如何在 geom_smooth 之后而不是在 geom_line 之后显示直接标签?),我认为我需要geom_dl在 ggplot 中使用该函数。

然而,目前我只能让标签落在最后的点上,而不是线条本身。我还设法在图表上绘制了名称,但是我再次无法将其与线条对齐。

任何想法将不胜感激!

谢谢

这是我的代码:

还有我的虚拟数据集:

0 投票
1 回答
1256 浏览

r - 增加 geom_line 图的标签间距

假设我有一组线,我使用ggplot和绘制geom_line。我想标记这些行。我可以使用包中的方法来做到这一点geom_dldirectlabels但即使使用提供的方法来避免重叠(例如"last.qp"),我仍然认为标签是两个靠得很近的。

如何增加这些标签之间的间距(此处为 y 方向),而不ggplot2::annotate使用或类似的东西手动指定它们的每个位置?我对不涉及directlabels包装的答案持开放态度,但如果可能的话,我想坚持使用它,因为它可以很好地完成 95% 的标签线工作。

这里有潜在的提示,tiebreak.big但我无法让它工作......

阴谋

0 投票
2 回答
3772 浏览

r - 将直接标签添加到 geom_smooth 而不是 geom_line

我认识到这个问题与这个问题非常相似但是那里的解决方案不再有效(使用method="last.qp"),所以我再次问它。

基本问题是我想使用directlabels(或等效)来标记每个组(来自stat_smooth())的平滑均值,而不是实际数据。下面的示例显示的与我所得到的一样接近,但标签无法识别分组,甚至无法识别平滑线。相反,我在最后一点得到了标签。我想要的是每条平滑线末尾的颜色协调文本,而不是图右侧的图例。

这是一个例子:

这使得这个情节: 在此处输入图像描述