我是R的新手,這是一項家庭作業。我只需要創建一些簡單的圖。R:清理繪圖的增量標籤和背景
我需要通過給每個軸添加0,500,1000,1500,2000和2500來清理繪圖的增量標籤(我不知道還有什麼可以稱它們的)。我還想將背景上的間距減少到100的間隔。另外,如果您知道更簡單的方法來刪除所有非常酷的圖例元素。謝謝您的幫助。
這是我的代碼。我假設你可以複製並粘貼到你的計算機上,看看我得到的混亂結果。
library("ggplot2")
library("lubridate")
library("reshape2")
library("gdata")
# PSRC park and ride data
parkride <- read.xls("http://www.psrc.org/assets/5748/parkandride-2010.xls",
sheet=2,
na.strings="*",
skip=1)
plot1 <- ggplot(parkride,
aes(x=Capacity, y=Occupancy, color="blue")) +
geom_point() +
xlim=c(0, 2500), ylim=c(0, 2500) +
theme(axis.title.y=element_text(angle=0)) +
ggtitle("Puget Sound Park and Ride \nLots Capacity and Occupancy") +
theme(plot.title=element_text(face="bold", lineheight=1.25)) +
scale_fill_discrete(guide=FALSE) +
theme(legend.title=element_blank()) +
theme(legend.text=element_blank()) +
theme(legend.key=element_blank()) +
theme(legend.background=element_blank())
我收到錯誤消息,提示您未包含所有數據操作。例如,parkride $容量是一個因素,其他大多數欄目也是如此。 –
由於這*是作業,所以重要的是要學習如何使用'ggplot2'。我很容易在網上找到兩個帶有「ggplot-intro.pdf」標題的PDF文件;這些應該對你非常有用。 –