简体   繁体   中英

VCD renaming label mosaicplot

I would like to rename my labels (both "Bildungsgrad" and "Bundestagswahl 2021" after having them situated via labeling_list. Currently, they just have there numeric values (see attached picture) Plot I tried both

set_labels=list(Bildungsgrad = c("Anderer Abschluss", "Qualifizierter Hauptschulabschluss", "Mittlere Reife", "Fachabitur/Allgemeines Abitur", "Universitätsabschluss")) and 

vnames <- list(set_varnames = c(StrategischeWahl2021="Strategische Wähler 2021"))
lnames <- list(Bildungsgrad = c("Anderer Abschluss", "Qualifizierter Hauptschulabschluss", "Mittlere Reife", "Fachabitur/Allgemeines Abitur", "Universitätsabschluss"))
labeling_args=vnames, set_labels=lnames

My entire code is here:

Test <- Deskriptive_Statistik

mosaic(~ Bildungsgrad + StrategischeWahl2021, 
       direction = c("v", "h"),
       data = Test,
       shade = TRUE,
       labeling = (labeling_list))
       margins = c(bottom = 5)

Thank you very much;)

I now fixed it via a not really elegant solution, but it works. I just renamed the Variable-Name, so now it acts like a legend. Picture

mosaic(data = Test,
   ~Bildungsgrad + StrategischeWahl2021,
   direction = c("v", "h"),
   shade = TRUE,
   labeling_args = list(set_varnames = c(StrategischeWahl2021 = "StrategischeWähler2021", Bildungsgrad = "0=Anderer Abschluss, 1=Qualifizierter Hauptschulabschluss, 2=Mittlere Reife, 3=Fachabitur/Allgemeines Abitur, 4=Universitätsabschluss)"), 
                                 set_labels = list(StrategischeWahl2021 = c("Nein", "Ja")), rep = FALSE),
   gp = shading_hcl, gp_args = list(interpolate = c(1, 1.8)))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM