我是R编程的初学者,正在探索ggplot。我试图绘制堆积条形图,以显示多个国家的3年季度收入。 我使用https://www.ibm.com/communities/analytics/watson-analytics-blog/sales-products-sample-data/
中的数据mydata <- read.csv("~/Downloads/WA_Sales_Products_2012-14.csv")
library(dplyr)
qtrSales <- mydata %>%
group_by(mydata$Retailer.country, mydata$Year, mydata$Quarter) %>%
summarize(Rev=sum(Revenue)) %>%
qtrSales <- data.frame(qtrSales)
colnames(qtrSales) <- c("Country", "Year", "Qtr", "Revenue")
library(ggplot2)
ggplot() + geom_bar(aes(y=qtrSales$Revenue, x = qtrSales$Year,
fill=qtrSales$Qtr), data=qtrSales, stat="identity")
答案 0 :(得分:1)
在这里,我将 class UserCreate(CreateView):
model = User
fields = ['email']
success_url = '/your_success_url/'
@transaction.atomic
def form_valid(self, form):
new_user = form.save(commit=False)
# process your submitted form here.
# eg. add any extra fields as:
# new_user.something = something
new_user.save()
return super().form_valid(form)
代替Quarter
放在x轴上,否则您需要使用构面。
Year