2016-04-17 11 views
0

Im Folgenden ein Code ist ein Histogramm mit ggplot Herstellung:ggplot Histogramm Code ausgibt

ggplot(res, aes(x=TOPIC,y=count)) + 
    scale_y_continuous(expand=c(0,0)) + 
    geom_bar(stat='identity') + 
    theme(axis.title.x=element_blank()) + 
    theme_bw(base_size = 16) + 
    ggtitle("Peer-reviewed papers per topic") 

res<-structure(list(TOPIC = structure(c(20L, 18L, 21L, 3L, 9L, 4L, 
7L, 8L, 17L, 27L, 29L, 2L, 24L, 30L, 16L, 28L, 10L, 22L, 12L, 
5L, 1L, 19L, 6L, 25L, 11L, 23L, 14L, 15L, 13L, 26L), .Label = c("ANA", 
"BEH", "BOUND", "CC", "DIS", "EVO", "HAB", "HABP", "HARV", "HWC", 
"ISSUE", "METH", "MINOR", "PA", "PEFF", "PHYS", "POLL", "POPABU", 
"POPGEN", "POPSTAT", "POPTR", "PRED", "PROT", "REPEC", "RESIMP", 
"REV", "SHIP", "TEK", "TOUR", "ZOO"), class = "factor"), count = c(9, 
7, 13, 5, 23, 35, 27, 5, 118, 0, 9, 22, 29, 46, 27, 12, 9, 44, 
70, 40, 24, 19, 26, 2, 4, 17, 4, 10, 86, 31)), .Names = c("TOPIC", 
"count"), row.names = c(NA, -30L), class = "data.frame") 

Die Themen haben Namen wie "Population Status" (POPSTAT), "Bevölkerungsentwicklung" (POPTREND) usw.

Es gibt Probleme, ich brauche Hilfe zu lösen:

1. The theme(axis.title.x=element_blank()) does not remove the x axis title. 
2. The scale_y_continuous(expand=c(0,0)) puts the bar on the level of 
    the x-axis, which I need, but I need some expansion on the upper part 
    of the y-axis. How do I achieve that? 
3. My labels from the data frame are abbreviations. How do I replace 
    these with new tick labels? 
4. I need to turn the x-axis labels 90°. 
+0

können Sie umfassen die Datenrahmen Sie Plotten verwenden dput (your_dataframe) – pluke

+2

Betrachten wir Lösungen für Ihre vorherigen Fragen zu akzeptieren bevor du einen neuen postest. – akrun

+1

Bitte lesen Sie die Informationen über [wie man eine gute Frage stellt] (http://stackoverflow.com/help/how-to-ask) und wie man ein [reproduzierbares Beispiel gibt] (http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproduzierbares Beispiel/5963610). Dies wird es anderen sehr erleichtern, Ihnen zu helfen. – Jaap

Antwort

1
  1. Verwenden labs(x = NULL)

  2. Meinst du ylim? Damit können Sie die Grenzen der y-Achse festlegen. Oder verwenden scale_y_continuous(limits = c(0, <upperLimit>), expand = c(0, 0))

  3. Verwenden Sie eine diskrete Skala mit Etiketten: scale_x_discrete(labels = <axis-labels>, limits = c(1:length(axis-labels))

  4. theme(axis.text.x = element_text(angle = 90))

Verwandte Themen