Ho fatto un barplot usando ggplot2 e il Diario che devo inviare richiede che le tacche degli assi siano rivolte verso l'interno.Come faccio a fare in modo che le mie zecche degli assi siano rivolte verso l'interno in ggplot2
Questa è la rappresentazione di testo dei miei dati (dput)
Mean.Inc.melt<-structure(list(Var1 = structure(c(1L, 2L, 1L, 2L, 1L, 2L), .Label = c("Harvest","Pre-Harvest"), class = "factor"), Var2 = structure(c(1L, 1L, 2L, 2L, 3L, 3L), .Label =c("Dip A", "Trip A", "Trip B"), class = "factor"), value = c(2, 34, 1, 36, 3, 46)), .Names =c("Var1", "Var2", "value"), row.names = c(NA, -6L), class = "data.frame")
Compreso l'errore standard
SEM.Inc.melt<-structure(list(Var1 = structure(c(1L, 2L, 1L, 2L, 1L, 2L), .Label = c("Harvest", "Pre-Harvest"), class = "factor"), Var2 = structure(c(1L, 1L, 2L, 2L, 3L, 3L), .Label = c("Dip A", "Trip A", "Trip B"), class = "factor"), value = c(1, 12, 1, 2, 1, 6)), .Names = c("Var1", "Var2", "value"), row.names = c(NA, -6L), class = "data.frame")
Questo è lo script che ho usato finora per creare la trama:
ggplot(Mean.Inc.melt,aes(x=Var2,y=value,fill=Var1))+
geom_bar(stat='identity',position=position_dodge(),colour='black')+
scale_fill_manual(values=c('#000000','#FFFFFF'))+
geom_errorbar(aes(ymin=Mean.Inc.melt$value-SEM.Inc.melt$value,
ymax=Mean.Inc.melt$value+SEM.Inc.melt$value),width=.1,
position=position_dodge(.9))+
xlab('Treatment')+
ylab('Percentage Incidence (%)')+
ylim(0,60)+
scale_y_continuous(expand=c(0,0),limits=c(0,60))+
scale_x_discrete(expand=c(0,0))+
theme_bw()+
theme(axis.line=element_line(colour='black'),panel.grid.major=element_blank(),
panel.grid.minor=element_blank(),panel.border=element_blank(),
panel.background=element_blank())+
geom_vline(xintercept=0)+theme(legend.position='none')
Credo che il punto sia: qualcuno sa se c'è un modo per far sì che il mio asse sia rivolto verso l'interno?
In ggplot 2.0.0 con un messaggio di avviso: 'axis.ticks.margin' è deprecato. Si prega di impostare la proprietà 'margin' di 'axis.text' invece '- e sembra 'axis.text = element_text (margin = 5)' non aiuta ... Io posterò indietro se le soluzioni si aprono. – xealits
Quindi, secondo il metodo test-and-try, questo è come lo si fa ora: 'theme (axis.ticks.length = unit (-0.25," cm "), axis.text.x = element_text (margin = unit (c (0.5,0.5,0.5,0.5), "cm")), axis.text.y = element_text (margin = unit (c (0.5,0.5,0.5,0.5), "cm"))) '- in qualche modo non eredita l'impostazione da 'axis.text', e i messaggi di errore richiedono che il margine sia un vettore di lunghezze 4. – xealits
@xealits - grazie per aver postato la correzione. – jbaums