Skip to content

Customizing legend key for geom_text and geom_label #2004

@alberthkcheng

Description

@alberthkcheng

Currently, the legend key is fixed to "a" because of the following code in legend-draw.r:

draw_key_text <- function(data, params, size) {
  textGrob("a", 0.5, 0.5,....

What i need to do is, when my label is showing numbers only, i would like to have a number, e.g. "1" on the legend key instead of "a".

I tried to use the following but it does not look beautiful (in terms of code clarity):

draw_key_text <- function(data, params, size) {
  textGrob(params$legend.key, 0.5, 0.5,....
}

geom_text <- function(....
                      key.legend = "a",..){
.... layer(....params = list(...key.legend = key.legend,...))
}

Is there any suggestion?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions