plotly / plotly/plotly.R

Extra (unwanted) geoms in the legend

Open
#572 13 comments 3 reactions 1 assignee View on GitHub

@moutikabdessabour is already working on this.

Since Sep 30, 2021.

bug ggplotly
Dominant language
R
Stars
2.7k
Forks
641
PR merge metrics
No merged PRs in 30d

Description

The code:
library(plotly)

dat1 <- data.frame(
  sex = factor(c("Female","Female","Male","Male")),
  time = factor(c("Lunch","Dinner","Lunch","Dinner"), levels=c("Lunch","Dinner")),
  total_bill = c(13.53, 16.81, 16.24, 17.42)
)

ggplot(data=dat1, aes(x=time, y=total_bill, group=sex, shape=sex, colour=sex)) +
  geom_line(aes(linetype=sex), size=1) +     # Set linetype by sex
  geom_point(size=5) +         # Use larger points, fill with white
  scale_colour_hue(name="Sex",      # Set legend title
                   l=30)  +                  # Use darker colors (lightness=30)
  scale_shape_manual(name="Sex",
                     values=c(22,21)) +      # Use points with a fill color
  scale_linetype_discrete(name="Sex") +
  xlab("Time of day") + ylab("Total bill") + # Set axis labels
  ggtitle("Average bill for 2 people") +     # Set title
  theme_bw()

ggplotly()
The ggplot version:

image

The ggplotly version:

screen shot 2016-05-04 at 5 46 01 pm

Session Info:

sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.9.4 (Mavericks)

locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] plotly_3.4.13 ggplot2_2.1.0

loaded via a namespace (and not attached):
[1] Rcpp_0.12.4 tidyr_0.4.1 assertthat_0.1 dplyr_0.4.3
[5] digest_0.6.9 grid_3.2.3 plyr_1.8.3 R6_2.1.2
[9] DBI_0.3.1 jsonlite_0.9.19 gtable_0.2.0 magrittr_1.5
[13] scales_0.4.0 httr_1.1.0 viridis_0.3.4 labeling_0.3
[17] tools_3.2.3 htmlwidgets_0.6 munsell_0.4.3 yaml_2.1.13
[21] parallel_3.2.3 base64enc_0.1-3 colorspace_1.2-6 htmltools_0.3.5
[25] gridExtra_2.2.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.