[英]R ggplot facet_wrap output illegible
I am having some trouble getting facet_wrap to output my charts in a legible fashion. 我在获取facet_wrap以便以清晰的方式输出图表时遇到一些麻烦。 I am not quite sure if there is a way to set each chart to fit the data so to speak.
我不太确定是否有办法设置每个图表以适合数据。 My data frame is a set of weights taken at various times throughout the day, but each date might have a few results, or many.
我的数据框是一整天在不同时间获取的一组权重,但是每个日期可能会有一些结果,也可能有许多结果。
head(df) results: 头(df)结果:
Date Time SKU Weight
1 1/6/2016 9:37 10142 28.70
2 1/6/2016 9:38 10142 27.45
3 1/6/2016 9:38 10142 30.60
4 1/6/2016 9:39 10142 30.60
5 1/6/2016 9:39 10142 35.30
6 1/6/2016 9:40 10142 28.25
The data continues for 6 months, I would like to represent each date in one line chart. 数据持续6个月,我想用一个折线图表示每个日期。 My approach has been ggplot and facet_wrap.
我的方法是ggplot和facet_wrap。 Perhaps this is not the approach I should take, so I am open to suggestions.
也许这不是我应该采取的方法,所以我愿意提出建议。
p10142 <- ggplot(wtData10142, aes(x = Time, y = Weight))
(p10142 + geom_line() + facet_wrap(~ Date, ncol = 10))
Any help would be greatly appreciated. 任何帮助将不胜感激。
try this 尝试这个
library(reshape2)
t <- read.csv(file = "book1.csv", header = T, sep = ",")
te <- melt(t)
ggplot(t, aes(x = Time, y = Weight, color = Date)) + geom_line()
What about something like this where you set scales = "free_y"
: 在设置
scales = "free_y"
:
p10142 <- ggplot(wtData10142, aes(x = Time, y = Weight)) +
geom_line() + facet_wrap(~ Date, ncol = 10, scales = "free_y"))
This will allow your y axis to fuctuate independently in each of your facets. 这将使您的y轴在每个面上都独立地波动。 Perhaps your could also set some type of limits with
scale_x_continuous()
. 也许您还可以使用
scale_x_continuous()
设置某种类型的限制。 Would help to have the full data set your used for plotting... 有助于获得用于绘图的完整数据集...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.