私の入力ファイルはPasteBin にあります。
私の現在のグラフコードは次のとおりです。
#Input and data formatting
merg_agg_creek<-read.table("merged aggregated creek.txt",header=TRUE)
library(ggplot2)
library(grid)
source("http://egret.psychol.cam.ac.uk/statistics/R/extensions/rnc_ggplot2_border_themes.r")
CombinedCreek<-data.frame(merg_agg_creek)
Combined<-CombinedCreek[order(CombinedCreek[,2]),]
Combined$Creek <- factor(rep(c('Culvert Creek','North Silcox','South Silcox','Yucca Pen'),c(32,57,51,31)))
Combined$Creek<-factor(Combined$Creek,levels(Combined$Creek)[c(1,4,3,2)])
#The Graph Code
creek <-ggplot(Combined,aes(Month,Density,color=factor(Year),shape=factor(Year)))+scale_color_discrete("Year")+scale_shape_discrete("Year")
creek<-creek + facet_grid(Creek~. ,scales = "free_y")
creek <- creek + geom_jitter(position = position_jitter(width = .3))
creek<-creek+scale_color_grey("Year",end=.6)+theme_bw()
creek<-creek+scale_y_continuous(expression("Number of prey captured " (m^2) ^-1))
creek<-creek+opts( panel.border = theme_L_border() )+ opts(axis.line = theme_segment())
creek<-creek+opts(panel.grid.minor = theme_blank())+opts(panel.grid.major = theme_blank())
creek<-creek+scale_x_discrete("Month",breaks=c(2,5,8,11),labels=c("February","May","August","November"))
creek
結果のグラフは次のとおりです
。
私の問題は、「scale_x_discrete」でブレークとラベルを作成することにより、プロットの右側、12 月のデータとファセット ラベルの間に大きなギャップが存在することです。"limits=c(0,13)" を "scale_x_discrete: コマンドに追加してこのギャップを解消しようとしましたが、結果のグラフでは x ラベルが破棄されます。
その隙間をなくすにはどうすればいいですか?私のプロット作成に根本的な欠陥はありますか?
ありがとう!
編集:Didzisは以下の質問に答えました。scale_x_discrete から scale_x_continuous に変更するだけです