我已经为R中的freq = 12的时间序列数据绘制了 public ActionResult SearchBooks()
{
var listBook = datamanager.GetAllBooks();
List<ViewBook> listViewBook = new List<ViewBook>();
foreach (Book b in listBook)
{
ViewBook viewBook = new ViewBook();
viewBook.BookID = b.BookId;
viewBook.Title = b.Title;
viewBook.Author = b.Author;
if (b.Rented ?? true)
{
viewBook.Avaible = "No";
}
else
{
viewBook.Avaible = "Yes";
}
listViewBook.Add(viewBook);
}
return View(listViewBook);
}
。我希望R在每个月的boxplot
中显示中值。我该怎么做?
R代码:
boxplot
答案 0 :(得分:1)
这里有ggplot
library(ggplot2)
data <- data.frame(abs = as.factor(rep(1:12, 10)), ord = rnorm(120, 5, 1))
calcmed <- function(x) {
return(c(y = 8, label = round(median(x), 1)))
# modify 8 to suit your needs
}
ggplot(data, aes(abs, ord)) +
geom_boxplot() +
stat_summary(fun.data = calcmed, geom = "text") +
#annotate("text", x = 1.4, y = 8.3, label = "median :") +
xlab("Abs") +
ylab("Ord") +
ggtitle("Boxplot")