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
23
votes
6 answers

Labeling Outliers of Boxplots in R

I have the code that creates a boxplot, using ggplot in R, I want to label my outliers with the year and Battle. Here is my code to create my boxplot require(ggplot2) ggplot(seabattle, aes(x=PortugesOutcome,y=RatioPort2Dutch ),xlim="OutCome",…
Deborah_Watson
  • 277
  • 1
  • 2
  • 8
14
votes
3 answers

Avoiding overlapping of labels with direct labels and ggplot2

I'm having problems avoiding overlapping labels in my graphic. I take a look at similar questions, but none of them helped me to solve my problem. Below I provide a reproducible example. Also, I don't understand why direct.labels isn't selecting…
Manoel Galdino
  • 2,376
  • 6
  • 27
  • 40
14
votes
1 answer

Label size in directlabels geom_dl()

I have really enjoyed the package directlabels for dynamic positioning the lables of a plot. Although still not perfect, it helps reasonably to prevent overlaps between labels of a scatter plots with many points for example - specially for the draft…
Ali
  • 9,440
  • 12
  • 62
  • 92
13
votes
2 answers

directlabels: avoid clipping (like xpd=TRUE)

In the plot below, direct label positions were tweaked a bit vertically, but they get clipped at the left/right edges. Is there any way to avoid clipping (similar to xpd=TRUE) or adjust the clipped labels inwards in the plot frames? Here's the…
user101089
  • 3,756
  • 1
  • 26
  • 53
11
votes
1 answer

R adding legend and directlabels to ggplot2 contour plot

I have a raster map that I want to plot using ggplot2 using a continuous scale and labeled isolines on top of that. For that I'm using the directlabels package and am close to getting what I want but I can't get both the legend and the labeled…
Ludecan
  • 331
  • 4
  • 13
11
votes
2 answers

Directlabels package-- labels do not fit in plot area

I want to explore the directlabels package with ggplot. I am trying to plot labels at the endpoint of a simple line chart; however, the labels are clipped by the plot panel. (I intend to plot about 10 financial time series in one plot and I thought…
Juan Mier
  • 155
  • 1
  • 6
9
votes
1 answer

How can you use directlabels and ggplot2?

I'm trying use the directlabels package to label two lines I have in a simple plot (I'm using ggplot2) My code is as follows: # libraries library(ggplot2) library(directlabels) # Variables A = array(1000,100) F = seq(length=100, from=0, by=10) f =…
djq
  • 14,810
  • 45
  • 122
  • 157
8
votes
1 answer

Expand plotting area by x-axis to make room for direct labels

I am polishing my graphs and have a problem with fitting direct labels in the plotting area. A want to remove most of the area between y1 and the y-axis to the left in the plot similar to that generated by the code below, but keep the extra area to…
Andreas
  • 209
  • 2
  • 8
8
votes
4 answers

How to show directlabels after geom_smooth and not after geom_line?

I'm using directlabels to annotate my plot. As you can see in this picture the labels are after geom_line but I want them after geom_smooth. Is this supported by directlabels? Or any other ideas how to achieve this? Thanks in advance! This is my…
celt-Ail
  • 195
  • 1
  • 4
7
votes
2 answers

Add direct labels to geom_smooth rather than geom_line

I recognize that this question is a close duplicate of this one, but the solution there no longer works (using method="last.qp"), so I'm asking it again. The basic issue is that I'd like to use directlabels (or equivalent) to label smoothed means…
phalteman
  • 3,442
  • 1
  • 29
  • 46
7
votes
2 answers

How do I add percentage and fractions to ggplot geom_text label?

I have a dataset where I am interested in looking at a score on a test and the percentage of people experiencing an event: dat <- data.frame(score = 1:7, n.event = c(263,5177,3599,21399,16228,10345,1452), n.total =…
Jacob Curtis
  • 788
  • 1
  • 8
  • 22
6
votes
1 answer

Increasing spacing between labels for geom_line plot

Suppose I have some set of lines that I plot using ggplot and geom_line. I want to label these lines. I can do this using geom_dl from the directlabels package, but even with the provided method to avoid overlaps (e.g. "last.qp"), I still think that…
tbadams45
  • 848
  • 1
  • 8
  • 19
4
votes
2 answers

How can I configure box.color in directlabels "draw.rects"?

Here is my working example: library(ggplot2) library(directlabels) # ver 2014.6.13 via r-forge DF <- expand.grid(z = seq(1, 3001, by=10), k = seq(from=0.5, to=5, by=0.25)) # Defines the function value for each z-k combination DF$dT <- with(DF,…
a different ben
  • 3,900
  • 6
  • 35
  • 45
3
votes
1 answer

How to add a label with directlabels when using multiple geoms?

I'm struggling to create labels at the right end of a line plot with directlabels when I'm using more than one geom. Here is an example: #load packages library(dplyr) library(ggplot2) library(tidyr) library(directlabels) #create…
Tea Tree
  • 882
  • 11
  • 26
3
votes
2 answers

How to add direct labels to a bar chart in ggplot for numeric x axis

I am trying to create a bar chart in ggplot where the widths of the bars are associated with a variable Cost$Sum.of.FS_P_Reduction_Kg. I am using the argument width=Sum.of.FS_P_Reduction_Kg to set the width of the bars according to a variable. I…
1
2 3 4