在R GGPLOT2中创建销售报告
我想使用ggplot2在R中创建销售报告。 我想要X轴和Y轴的$销售日期,我也想展示我们在整个销售期间进行的促销活动。因此,我们可以确定哪些促销表现良好。我能够通过GEOM_POINT进行操作,并使用Color =促销,但是我的某些促销活动是重叠的,不知道该如何解决。我可以实现这一目标的最好方法是什么。
如果可以帮助我实现此情况,我可以使用任何其他图形(例如栏或直方图)。
这是我使用的代码。
ggplot(data = sales)+
geom_point(mapping = aes(x = Date, y = Total_Sales, color = Promotions, size = Total_Sales))+
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))
谢谢你!
I want to create sales report in R using ggplot2.
I want dates in x-axis and $ sales in y-axis and I also want to show promotions we did during the whole sale period. So we can Identify which promotions did well. I was able to do it thru geom_point and use color=Promotions but some of my promotions are overlapping and don't know how to tackle that. What is the best way I can achieve this.
I am open to use any other graph like bar or histogram if that can help me achieve this scenario.
Here's the code I use.
ggplot(data = sales)+
geom_point(mapping = aes(x = Date, y = Total_Sales, color = Promotions, size = Total_Sales))+
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过数据的描述,您似乎有三个变量,
date
,total_sales
和promotions
绘制彩色点表示促销的数量可能使很难看到销售/促销之间的关系。您可以制作一个条/线图(包括代码),但这列出了规模问题,促销的数量可以是单位数字,而销售量则为数千个。我只包括了演示如何做的代码,但是这样做不是一个好主意。最好使用比例(百分比)来查看销售/促销之间的关系。
编辑
由于您的
促销
变量是离散的,并且您的total_sales
不区分促销促销和销售数量。Going by the description of your data, it seems your have three variables,
Date
,Total_Sales
, andPromotions
and plotting colored dots, where the color indicates the amount of promotions, may make it difficult to see the relationship between sales/promotions. You could make a bar/line graph (code included), but this presents the problem of scale, the number of promotions may be single digits, and the amount of sales in the thousands. I just included the code to demonstrate how to do it, but it's not a good idea to do it this way.It will be better to use proportions (percentages) to see the relationship between sales/promotions.
EDITED
Since your
Promotions
variable is discrete and yourTotal_Sales
do not distinguish between promotions, then you can count the number of promotions and see the association between number of promotions and sales.