Questions tagged [direct-labels]

An R package for attaching labels to points, lines and contours in ggplot and lattice plots

directlabels is an R package for attaching labels to points, lines and contours in ggplot2 and lattice plots. The motivation for using directlabels is that the labels, in most instances, are easier to read and interpret than legends; and thus the labels can be used in place of legends.

Examples, vignettes, and links to additional resources are available on the package's old R-forge site and in the directlabels documentation link. Also see the package's github site.

Related tags

48 questions
1
vote
1 answer

R/ggplot2 - directlabels package generating errors even with given example code

I've installed the "directlabels" package from http://directlabels.r-forge.r-project.org/, along with its dependency "quadprog". The first example from that page works: install.packages("directlabels",…
rtf
  • 55
  • 6
1
vote
0 answers

R / ggplot2: Add directlabels to ridgeline plot

I'm trying to add directlabels to lines of a ridgeline plot created by ggridges. It seems directlabels doesn't know what to apply the labels to. Is it possible to specify this? Or are the two packages incompatible? # does not…
Timm S.
  • 5,135
  • 6
  • 24
  • 38
1
vote
1 answer

How to add duplicate label using directlabels package in R

I have the following data frame: library(tidyverse) library(directlabels) dat <- structure(list(time.course = c("CONTROL", "DAY03", "DAY06", "DAY09", "DAY12", "DAY15", "CONTROL", "DAY03", "DAY06", "DAY09", "DAY12", "DAY15", "CONTROL", "DAY03",…
littleworth
  • 4,781
  • 6
  • 42
  • 76
1
vote
2 answers

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…
user697473
  • 2,165
  • 1
  • 20
  • 47
1
vote
1 answer

Error: No Default label placement from this type of ggplot

Why am I getting this error? Here is the R script and the data set I am trying to plot salinity contours for (link to data here): It looks like this (first 10 rows): Longitude Latitude Salinity 1 -76.7027969 35.8915787 0.094745182 2 …
1
vote
1 answer

Error in parse(text = x) when including non overlapping labels in ggplot2

I've been trying to add labels to the dots in my scatterplot but I keep getting a problem: Error in parse(text = x) : :1:1: unexpected '$' 1: $ ^ I've looked at most of the posts related to the direct.label package but I can't seem to…
cimentadaj
  • 1,414
  • 10
  • 23
1
vote
4 answers

Labelling points with ggplot2 and directlabels

This is a follow-up to my earlier question. While the answer by krlmlr somehow helps to solve my problem, one issue remains - the labels are moved far away from the points such that it gets impossible to see which label corresponds to which point.…
erc
  • 10,113
  • 11
  • 57
  • 88
1
vote
1 answer

adjusting font size of directlabels for lattice with default placement method

When attempting to adjust the font size in directlabels, using list(cex=2), the function undesirably adds labels to every single point. library(lattice) library(directlabels) foo <- data.frame(x=1:10, y=c(1:5, (1:5)^2), z=c(1:10)) direct.label(…
Bryan
  • 933
  • 1
  • 7
  • 21
0
votes
0 answers

Add direct labels in ggplot

I want to add direct labels on both two geom_line graphs, and I tried lots of times by using directlabels packages. However, the error always happened and I do not know what is exactly wrong with my code. The raw data is in csv file, so I will…
0
votes
2 answers

How to use directlabels to label lines in ggplot2

library(ggplot2) library(directlabels) mydat <- structure(list(Name = c("Ana", "Josh", "Bart", "Ana", "Josh", "Bart"), color_line = c("purple", "purple", "orange", "purple", "purple", "orange"), x = c(0.864864864864865, 0.810810810810811,…
Adrian
  • 9,229
  • 24
  • 74
  • 132
0
votes
1 answer

How to rename line label in R autoplot?

I have the following plot with true values (black line), fitted values (orange line) and forecasts (blue line). If you notice on the right, the fitted values line says NULL. How can I change that to "Fitted Values"?. Also, why does it say "series on…
Luiz Scheuer
  • 305
  • 1
  • 10
0
votes
1 answer

R / nse / Double-handover of a variable to a sub-function

I have two functions I want to wrap together in a wrapping function for usability. The wrapping function includes a variable (a column name within a dataframe) which should be handed over from the wrapping function to one of the subfunctions.…
Timm S.
  • 5,135
  • 6
  • 24
  • 38
0
votes
1 answer

“non-numeric argument to binary operator” when using ggsurvplot() + geom_dl()

I would like to attach labels using geom_dl to a Kaplan–Meier (KM) plot produced by ggsurvplot. It works fine if I use the plot part of ggsurvplot. library(survival) library(survminer) library(directlabels) fit <- survfit(Surv(time, status) ~…
A. Suliman
  • 12,923
  • 5
  • 24
  • 37
0
votes
1 answer

How to use direct.label() with simple (two variables) ggplot2 chart

Here is a simple ggplot chart for two variables: library("ggplot2") library("directlabels") library("tibble") df <- tibble( number = 1:10, var1 = runif(10)*10, var2 = runif(10)*10 ) ggplot(df, aes(number))+ geom_line(aes(y=var1),…
MariaMaria1
  • 25
  • 1
  • 6
0
votes
0 answers

I would like to know how to label all the points with directlabels in ggplot2

I want to add labels with direct.labels to my plot of Gower's residuals (used in suitability analyses). I found, however, that the direct.labels function only adds labels to certain points and not to all of them. I wonder if there is a function that…