Skip to content

Legend title not shown in horizontal orientation #1704

Description

@richierocks

The legend title is not shown for legends in horizontal orientation.

Here's a line plot with a legend.

library(ggplot2)
library(plotly)

plt <- ggplot(Orange, aes(age, circumference, group = Tree, color = Tree)) + 
  geom_line()

The plotly version with a vertical legend correctly displays the title.

ggplotly(plt)

Screenshot 2020-02-21 13 37 33

If I change to horizontal orientation, the title is no longer present

ggplotly(plt) %>% 
  layout(
    legend = list(
      orientation = "h"
    )
  )

Notice that the word "Tree" is not present in this image.

Screenshot 2020-02-21 13 38 53

This is a low priority bug since there is a workaround: you can manually specify the legend title.

ggplotly(plt) %>% 
  layout(
    legend = list(
      orientation = "h", 
      title = list(text = "Tree")
    )
  )

Screenshot 2020-02-21 13 42 07

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