I am having some trouble getting facet_wrap to output my charts in a legible fashion. 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:
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. My approach has been ggplot and 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"
:
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. Perhaps your could also set some type of limits with scale_x_continuous()
. Would help to have the full data set your used for plotting...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.