English 中文(简体)
在GGPLOT2中增加一条通融线
原标题:Adding a Unique Trend Line to a Barplot in GGPLOT2
  • 时间:2011-08-30 15:16:28
  •  标签:
  • r
  • ggplot2
最佳回答

As per all the comments: the squiggly line is scientifically dubious, since it isn t based upon a statistical model of the data. (And it appears to show the number of smartphone users levelling off, when the data shows no such thing.) So the best advice is "don t do it".

既然你似乎真心希望这一想法,那是可能的。

You can add any line you like with geom_line. To replicate the silly line in your infographic, you could do a straight line plus a sine curve for give it wiggle. Assuming your plot was named p

p + geom_line(
  aes(date, value), 
  data = data.frame(
    date = seq(2008, 2013, length.out = n),
    value = seq(600, 1300, length.out = n) + 100 * sin(seq(0, 4 * pi, length.out = n))  
  ), 
  arrow = arrow(length = unit(0.4, "cm"))
)

一种更好的办法是利用一个能够顺利治愈的曲线。

p + geom_smooth(method = "loess", se = FALSE)  #maybe also span = 0.5, for extra wigglyness.
问题回答

回答你的问题显然是:R.R.没有做到这一点。 如果你使用一些病媒图谱方案,你就能够更快、更接近你想要的东西。 使用图解器、因纽克(自由)或你喜欢的任何图形工具。 或许你们也想在R中创建图表,并在其中一项方案中后来加以修改。

我可以理解这些评论,也同意本图不会通过一些测试。 不仅有学术测试,而且有看管-无uck-ine-ine-test。 提及Edward Tufte也是出于美学原因。 然而,我认为这是一个不值得 down表决的遗留问题,只是因为图谋 looks。 有时,学术界也需要在学术期刊之外出版他们的剪辑,而图象最终由大众编辑编辑。 因此,事先知道——最好不要试图与R一道做这样的 st。





相关问题
How to plot fitted model over observed time series

This is a really really simple question to which I seem to be entirely unable to get a solution. I would like to do a scatter plot of an observed time series in R, and over this I want to plot the ...

REvolution for R

since the latest Ubuntu release (karmic koala), I noticed that the internal R package advertises on start-up the REvolution package. It seems to be a library collection for high-performance matrix ...

R - capturing elements of R output into text files

I am trying to run an analysis by invoking R through the command line as follows: R --no-save < SampleProgram.R > SampleProgram.opt For example, consider the simple R program below: mydata =...

R statistical package: wrapping GOFrame objects

I m trying to generate GOFrame objects to generate a gene ontology mapping in R for unsupported organisms (see http://www.bioconductor.org/packages/release/bioc/vignettes/GOstats/inst/doc/...

Changing the order of dodged bars in ggplot2 barplot

I have a dataframe df.all and I m plotting it in a bar plot with ggplot2 using the code below. I d like to make it so that the order of the dodged bars is flipped. That is, so that the bars labeled "...

Strange error when using sparse matrices and glmnet

I m getting a weird error when training a glmnet regression. invalid class "dgCMatrix" object: length(Dimnames[[2]]) must match Dim[2] It only happens occasionally, and perhaps only under larger ...

Generating non-duplicate combination pairs in R

Sorry for the non-descriptive title but I don t know whether there s a word for what I m trying to achieve. Let s assume that I have a list of names of different classes like c( 1 , 2 , 3 , 4 ) ...

Per panel smoothing in ggplot2

I m plotting a group of curves, using facet in ggplot2. I d like to have a smoother applied to plots where there are enough points to smooth, but not on plots with very few points. In particular I d ...

热门标签