How can I replace legend key in ggplot2?

kairos

I used the picture's numbers as data points in this scatterplot, which was created with ggplot2. As a result, the legend key is an 'a'. Instead, I would need ordinary dots (also colored by clusters) beside the labels. How can I realize that? I used the following code:

ggplot(data, aes(x=vx, y=vy, color=Cluster, shape=Cluster)) + geom_text(aes(label=PicNr),
  size =6, fontface = "bold",
  check_overlap = T,
  show.legend=T) +
  theme_bw(base_size = 20)+
  theme(legend.position="top") 

Thanks for your help!

legend

AndS.

For this you can do something like

library(ggplot2)

ggplot(mtcars, aes(mpg, wt))+
  geom_text(aes(label = cyl, color = factor(cyl)), show.legend = FALSE)+
  geom_point(aes(color = factor(cyl)), alpha = 0)+
  guides(color = guide_legend(override.aes = list(alpha = 1, size = 4)))

so your code would read something like:

ggplot(data, aes(x=vx, y=vy, shape=Cluster)) + 
  geom_text(aes(label=PicNr, color=Cluster), size =6, fontface = "bold", check_overlap = T, show.legend=F) +
  geom_point(aes(color=Cluster), alpha = 0)+
  theme_bw(base_size = 20)+
  theme(legend.position="top")+
  guides(color = guide_legend(override.aes = list(alpha = 1, size = 4)))

Created on 2018-08-18 by the reprex package (v0.2.0).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I make the legend in ggplot2 the same height as my plot?

From Dev

How to reorder a legend in ggplot2?

From Dev

How can I display legend in Tkinter?

From Dev

How can I fix this strange behavior of legend in ggplot2?

From Dev

How can I show sample size in the legend?

From Dev

How can I create ggplot2 titles in Japanese?

From Dev

Change the symbol in a legend key in ggplot2

From Dev

ggplot2: applying width of line to the legend key

From Dev

how can I change the legend for ggbiplot?

From Dev

How do I add a legend in ggplot2 using R?

From Dev

How can i replace an objectAtIndex with value for key?

From Dev

How to get vertical lines in legend key using ggplot2 for geom_pointrange() type graphic

From Dev

ggplot2 make legend key fill transparent

From Dev

How can I remove the line aesthetic from a ggplot2 legend?

From Dev

How can I change the legend geometry in ggplot2

From Dev

ggplot2: Replace legend keys and sort alphabetically

From Dev

ggplot2: missing legend and how to add?

From Dev

How can I add a 2-column legend to a Matlab plot?

From Dev

How can I rotate labels in ggplot2?

From Dev

How to transpose legend in ggplot2

From Dev

How I can replace the object key with root, in MongoDB

From Dev

how to get combined legend in ggplot2 when I have both geom_line and geom_hline

From Dev

How can I add guide to ggplot2?

From Dev

How can i replace an objectAtIndex with value for key?

From Dev

How to get vertical lines in legend key using ggplot2 for geom_pointrange() type graphic

From Dev

How can I replace some pressed key on a user-control?

From Dev

How do I create a legend for both color and shape in ggplot2

From Dev

How can I overlay histograms previously created with ggplot2?

From Dev

How to put variables in legend in ggplot2

Related Related

  1. 1

    How can I make the legend in ggplot2 the same height as my plot?

  2. 2

    How to reorder a legend in ggplot2?

  3. 3

    How can I display legend in Tkinter?

  4. 4

    How can I fix this strange behavior of legend in ggplot2?

  5. 5

    How can I show sample size in the legend?

  6. 6

    How can I create ggplot2 titles in Japanese?

  7. 7

    Change the symbol in a legend key in ggplot2

  8. 8

    ggplot2: applying width of line to the legend key

  9. 9

    how can I change the legend for ggbiplot?

  10. 10

    How do I add a legend in ggplot2 using R?

  11. 11

    How can i replace an objectAtIndex with value for key?

  12. 12

    How to get vertical lines in legend key using ggplot2 for geom_pointrange() type graphic

  13. 13

    ggplot2 make legend key fill transparent

  14. 14

    How can I remove the line aesthetic from a ggplot2 legend?

  15. 15

    How can I change the legend geometry in ggplot2

  16. 16

    ggplot2: Replace legend keys and sort alphabetically

  17. 17

    ggplot2: missing legend and how to add?

  18. 18

    How can I add a 2-column legend to a Matlab plot?

  19. 19

    How can I rotate labels in ggplot2?

  20. 20

    How to transpose legend in ggplot2

  21. 21

    How I can replace the object key with root, in MongoDB

  22. 22

    how to get combined legend in ggplot2 when I have both geom_line and geom_hline

  23. 23

    How can I add guide to ggplot2?

  24. 24

    How can i replace an objectAtIndex with value for key?

  25. 25

    How to get vertical lines in legend key using ggplot2 for geom_pointrange() type graphic

  26. 26

    How can I replace some pressed key on a user-control?

  27. 27

    How do I create a legend for both color and shape in ggplot2

  28. 28

    How can I overlay histograms previously created with ggplot2?

  29. 29

    How to put variables in legend in ggplot2

HotTag

Archive