2016-06-30 24 views
-1

我有一個有百萬記錄的帕累託圖。對於Y軸,我使用了Pareto.Chart()函數並顯示四分位數。對於x軸,我有數以百萬計的記錄,並使用scale_x_continuous()顯示十分位的x點,但我想顯示10 20 30 ... 100而不是數字。這裏是它是如何的形象和我多麼希望它enter image description here如何標籤帕雷託圖爲十進制只顯示10 20等等

我多麼希望是這樣的:enter image description here

我已經使用GGPLOT2和QCC這裏。我已經使用pareto.chart()函數只是爲了得到累積性的金額,然後在Y.用它下面是部分代碼:

revenue<-custfinal$Revenue 
names(revenue)<-custfinal$customerid 
cummulative<-abspareto(revenue, ylab = "Revenue", xlab="Customer", xaxt="n") 
cummulative<-data.frame(cummulative) 

paretorevenue<-ggplot(data=cummulative, 
       aes(x = seq(1,length(cummulative$Frequency)),y=Cum.Percent.,group=1)) + geom_line(colour="red", size=1) + theme_classic() + theme(axis.text.x = element_text(angle = 75, hjust = 1, size=12)) + labs(x="Number of Customer",y="Revenue Share (%)") +ggtitle("Revenue generated distribution for Yogurt 2016") +ylim(0,100.1)+scale_x_continuous(breaks = round(seq(0,length(cummulative$Frequency),length(cummulative$Frequency)/10),-3))  
print(paretorevenue) 

abspareto()的東西,我在pareto.chart已經編輯(),所以它只是給了我一個累贅的部分。

回答

1

由於您沒有提供任何示例數據,我使用了ggplot幫助頁面中的一些數據。您可以使用scale_x_continuous()函數中的標籤參數更改刻度標籤。在那裏,你可以包括數字c(1, 2, 3)或字符串向量c("a", "b", "c")只要你喜歡。規模沒有改變。

df <- data.frame(
    x = 1:5, 
    y1 = c(1, 2, 3, 4, NA), 
    y2 = c(NA, 2, 3, 4, 5), 
    y3 = c(1, 2, NA, 4, 5) 
) 
p <- ggplot(df, aes(x, y1)) + geom_line() 
p + scale_x_continuous(labels=c(10, 20, 30, 40, "a")) 

一般來說,因爲這是你至少fivth問題關於這個話題,你可以嘗試尋找答案或標記與ggplot2geom_line()pareto chart你的問題,因爲這是一個專用名詞不那麼熟悉。我確信使用這個搜索詞/標題會更快地回答你的問題。

+0

哦,我很抱歉....你採取了正確的樣板...連續「a」的目的是什麼...原諒我我不知道任何關於R很多隻是學習我會嘗試這並回復你 –

+0

@AbhishekSingh看到我的編輯。 – Jimbou

+0

哦,我不知道我可以使用標籤和休息。萬分感謝 –