如何一次可视化“许多”类别的标签?

时间:2019-11-19 12:35:15

标签: r ggplot2

我已经了解到我们的学生来自哪所高中,但是类别如此之多,以至于普通的coord_flip()函数不再有用。是否还有另一种增加可读性的方法(增加图的大小,增加类别之间的间隔等)?

为了合并变量值(可能需要完成),我首先需要可视化数据,以便将其呈现给具有必要领域知识的同事。

这是我当前情节的照片:

enter image description here

这是我当前的代码:

ggplot(fulldata,aes(x=fct_rev(fct_infreq(UPSEC_SCHOOL))))+geom_bar()+coord_flip()

这是我的数据摘录:

structure(list(start_date = structure(c(17776, 17776, 17776, 
17776, 17776, 17776, 17776, 17776, 17776, 17776, 17776, 17776, 
17776, 17776, 17776, 17776, 17776, 17776, 17776, 17776, 17776, 
17776, 17776, 17776, 17776, 17776, 17776, 17776, 17776, 17776, 
17776, 17776, 17776, 17776, 17776, 17776, 17776, 17776, 17776, 
17776, 17776, 17776, 17776, 17776, 17776, 17776, 17776, 17776, 
17776, 17776, 17776, 17776, 17776, 17776, 17776, 17776, 17776, 
17776, 17776, 17776, 17776, 17776, 17776, 17776, 17776, 17776, 
17776, 17776, 17776, 17776, 17776, 17776, 17776, 17776, 17776, 
17776, 17776, 17776, 17776, 17776, 17776, 17776, 17776, 17776, 
17776, 17776, 17776, 17776, 17776, 17776, 17776, 17776, 17776, 
17776, 17776, 17776, 17776, 17776, 17776, 17776, 17776, 17776, 
17776, 17776, 17776, 17776, 17776, 17776, 17776, 17776, 17776, 
17776, 17776, 17776, 17776, 17776, 17776, 17776, 17776, 17776, 
17776, 17776, 17776, 17776, 17776, 17776, 17776, 17776, 17776, 
17776, 17776, 17776, 17776, 17776, 17776, 17776, 17776, 17776, 
17776, 17776, 17776, 17776, 17776, 17776, 17776, 17776, 17776, 
17776, 17776, 17776, 17776, 17776, 17776, 17776), class = "Date"), 
    UPSEC_SCHOOL = structure(c(1L, NA, 26L, 51L, NA, 3L, 71L, 
    52L, 58L, NA, 75L, 70L, 2L, 53L, 85L, 19L, 15L, 80L, 60L, 
    39L, 49L, 76L, 53L, 9L, 76L, 5L, 5L, 21L, 76L, 26L, 7L, 85L, 
    57L, 82L, 59L, 50L, 42L, 22L, 31L, 8L, 45L, 69L, 64L, 18L, 
    29L, 6L, 56L, 86L, 61L, 66L, 36L, NA, 46L, NA, 62L, NA, 83L, 
    48L, 41L, 55L, NA, NA, 74L, 84L, 55L, NA, 33L, NA, 38L, 32L, 
    67L, 79L, 55L, 55L, 56L, 16L, NA, 73L, NA, 10L, 10L, 23L, 
    77L, NA, 13L, 68L, 31L, 77L, 4L, 28L, 35L, 23L, 55L, 30L, 
    72L, 81L, 36L, NA, 55L, NA, NA, 22L, 65L, 22L, 65L, NA, 27L, 
    25L, NA, 43L, 62L, 37L, 30L, 11L, 17L, 23L, 30L, NA, 40L, 
    NA, 62L, NA, 63L, 30L, NA, 62L, 78L, 62L, 34L, NA, 22L, 47L, 
    14L, 17L, 72L, 30L, 54L, 22L, NA, 30L, 17L, 24L, 20L, 33L, 
    44L, 12L, 30L, NA, NA, NA, NA, NA, NA, NA), .Label = c("AGNEBERGSGYMNASIET                       ", 
    "Ale gymnasium", "Angeredsgymnasiet", "Angeredsgymnasiet 2           ", 
    "Aranäsgymnasiet", "Aranäsgymnasiet Enhet 3       ", "Bräckegymnasiet", 
    "Cybergymnasiet Göteborg", "De la Gardiegymnasiet", "De la Gardiegymnasiet, enhet 1", 
    "De la Gardiegymnasiet, enhet 3", "Drottning Blanka Gymn. GTB    ", 
    "Drottning Blankas Gymn Trollhä", "Drottning Blankas Gymn. Kba   ", 
    "Elof Lindälvs gymnasium", "Falkenbergs Gymnasieskola 5   ", 
    "Folkuniv Gymnasium Trollhättan", "Fyrisskolan", "Fässbergsgymnasiet", 
    "Gislaveds gymn NA, SAM, Vård  ", "Gislaveds gymnasium/komvux", 
    "GTI:s gymnasieskola           ", "Gullmarsgymnasiet 2           ", 
    "Hagströmska gymnasiet Falun   ", "Handelsak. Yrkesh. o Gymnasium", 
    "Hulebäcksgymnasiet", "Hulebäcksgymnasiet 3          ", "Hulebäcksgymnasiet 4          ", 
    "Hulebäcksgymnasiet 5          ", "Hvitfeldtska gymnasiet 1      ", 
    "Hvitfeldtska gymnasiet 3      ", "HÄRNÖSANDS GYMNASIUM 2", 
    "JENSEN Gymnasium Göteborg     ", "Karlbergsgymnasiet 2          ", 
    "Katedralskolan                ", "Katrinelundsgymnasiet 1       ", 
    "Katrinelundsgymnasiet 4       ", "KATRINELUNDSGYMNASIET 5", 
    "KCK-Karlbergsgymnasiet", "Kitas Gymnasium               ", 
    "Kitas Natur                   ", "KUNGL SV. BALETSKOLAN GY", 
    "Kunskapsgymnasiet Göteborg    ", "Lagmansgymnasiet              ", 
    "LERUMS GYMNASIUM, SKOLENHET 1", "LERUMS GYMNASIUM, SKOLENHET 2", 
    "LERUMS GYMNASIUM, SKOLENHET 4", "Lichron Teknikgymn.Trollhättan", 
    "Lindeskolan", "Ljud & Bildskolan LBS Halmstad", "Lärcentrum komvux         ", 
    "Lärcentrum/komvux         ", "Magnus Åbergsgymnasiet", "Mikael Elias Gymn, Göteborg   ", 
    "Mimers Hus Gymnasium 2        ", "Mimers Hus Gymnasium 4        ", 
    "MIMERS HUS GYMNASIUM 6", "Nils Ericsonsgymnasiet", "Nils Ericsonsgymnasiet 4", 
    "NTI-gymnasiet Karlskrona", "NÖSNÄSGYMNASIET 2", "NÖSNÄSGYMNASIET 3", 
    "NÖSNÄSGYMNASIET 4", "Peder Skrivares sk Sektor 1b  ", "Plusgymnasiet i Göteborg      ", 
    "Plusgymnasiet i Uddevalla     ", "Polhemsgymnasium 2            ", 
    "Porthälla gymnasium/Högskolef ", "Rosendalsgymnasiet            ", 
    "S:t Eskils gymnasium", "Schillerska gymnasiet", "Schillerska gymnasiet 2       ", 
    "Sigrid Rudebecks gymnasium    ", "SKF Tekniska Gymnasium        ", 
    "Sundsta/Älvkullegymnasiet", "Uddevalla gymnasieskola", "UDDEVALLA GYMNASIESKOLA EK", 
    "UDDEVALLA GYMNASIESKOLA EK-SPINT-AGB", "UDDEVALLA GYMNASIESKOLA HA", 
    "UDDEVALLA GYMNASIESKOLA SA", "Uddevalla gymnasieskola SA    ", 
    "UDDEVALLA GYMNASIESKOLA TE-IN", "Vadsbogymnasiet               ", 
    "Wisbygymnasiet Söder", "VUXENUTBILDNINGEN GÖTEBORG", "VuxenUtbildningsCentrum   "
    ), class = "factor")), row.names = c(NA, -154L), groups = structure(list(
    start_date = structure(17776, class = "Date"), .rows = list(
        1:154)), row.names = c(NA, -1L), class = c("tbl_df", 
"tbl", "data.frame"), .drop = TRUE), class = c("grouped_df", 
"tbl_df", "tbl", "data.frame"))

0 个答案:

没有答案