Skip to content

directlabels improvements

Raven edited this page Feb 26, 2021 · 6 revisions

Background

directlabels is an R package for adding direct text labels to plots, typically in order to replace confusing legends in lattice and ggplot2.

Related work

Coding project: directlabels improvements

The goal is to code improvements to testing and documentation of directlabels.

  • The directlabels documentation web site is still hosted on R-forge, and has not been re-built in years. One goal would be to create software for automatic generation of a new doc web site on GitHub Pages.
  • Add directlabels to https://exts.ggplot2.tidyverse.org/gallery/
  • Right now directlabels works by creating a custom grid grob (dlgrob) with a drawDetails method (drawDetails.dlgrob), see positioning.functions.R for the code. We should instead use the new makeContent/makeContext methods which would make the code easier to test via grid.force (see next point below). See the grid R Journal article for an explanation of how to implement these new methods. The tricky part is that currently the labels are drawn using grid.* functions from within drawDetails, and there may be more than one grid.* call. For example with any polygon.method such as last.polygons there will be one grid.polygon() call and one grid.text() call. Using the new makeContent method we would have to return a gTree with two grobs (polygonGrob and textGrob). That would require non-trivial modifications to the current positioning methods, which each only return a data frame (not grobs). Maybe the grobs to be drawn could be attached to a special attribute of that data frame? The interested student needs to propose a reasonable strategy to implement this.
  • The tests do not provide enough code coverage! First we need to setup code coverage and then setup a testing framework, based on the grid grobs which are rendered via grid.force().

Expected impact

The directlabels package is already widely used, and these modifications will make it even easier for users/devs via better documentation and tests.

Mentors

Please get in touch after completing at least one of the tests below.

Tests

Do one or several — doing more hard tests makes you more likely to be selected.

  • Easy: create a ggplot g with a confusing legend, and then another version of the plot with direct labels, using both direct.label(g) and g+geom_dl().
  • Medium: implement a custom positioning method, explain what it does, why it is useful, and make a plot using it.
  • Hard: there are several positioning methods which use gapply.fun, which internally uses gapply. Fork directlabels and remove gapply.fun, and use gapply instead.

Solutions of tests

Students, please post a link to your test results here.

S No. STUDENT NAME GITHUB PROFILE TEST RESULTS LINK
1 Anirban Chetia Anirban166 /GSoC21-Tests
Clone this wiki locally