[R] Greyed text in the background of a plot
Agustin Lobo
Agustin.Lobo at ija.csic.es
Sun Sep 14 14:05:06 CEST 2008
Yes, it's easy but you get a significant "jump" between a time
step and the next one, which makes the animation unpleasant and
difficult to follow. I think that this problem is because
of the use of plot(), which redraws everything, and that
there is no way around within R (is it?).
I also understand that
these "jumps" are avoided in your package by creating
the animated gif and html pages. Actually your
animation with the word "Animation" in
your page
http://animation.yihui.name/animation:start#generate_an_animation_sequence
is much "softer" that what you get by running the code within R.
Regarding what you have in
http://animation.yihui.name/da:ts:hans_rosling_s_talk
I'm missing the function Rosling.bubbles(), so cannot
actually try it.
And congratulations, great site and package.
Agus
Yihui Xie wrote:
> Well, his talk seems to have attracted a lot of people... You may
> simply use gray text in your plot. Here is an example:
>
> ##################################################
> x = runif(10)
> y = runif(10)
> z = runif(10, 0.1, 0.3)
> cl = rgb(runif(10), runif(10), runif(10), 0.5) # transparent colors!
> par(mar = c(4, 4, 0.2, 0.2))
> for (i in 1917:2007) {
> x = x + rnorm(10, 0, 0.02)
> y = y + rnorm(10, 0, 0.02)
> z = abs(z + rnorm(10, 0, 0.05))
> plot(x, y, xlim = c(0, 1), ylim = c(0, 1), type = "n", panel.first = {
> grid()
> text(0.5, 0.5, i, cex = 5, col = "gray") # here is the text!
> })
> symbols(x, y, circles = z, add = T, bg = cl, inches = 0.8)
> box()
> Sys.sleep(0.2)
> }
> ##################################################
>
> Not difficult at all, right? :)
>
> BTW, if you are interested in such animations, you may as well take a
> look at my "animation" package:
> http://cran.r-project.org/web/packages/animation/index.html
> http://animation.yihui.name/
>
> Regards,
> Yihui
>
> On Fri, Sep 12, 2008 at 8:35 PM, Agustin Lobo <aloboaleu at gmail.com> wrote:
>> Hi!
>>
>> Is there any way of having a greyed ("ghosted") text
>> (i.e, 2006) in the background of a plot?
>> I'm making a dynamic plot and would like to show the
>> year of each time step as a big greyed text in the background.
>>
>> (the idea comes from Hans Rosling video:
>> http://video.google.com/videoplay?docid=4237353244338529080&sourceid=searchfeed
>> )
>>
>> Thanks
>>
>> Agus
>> --
>> Dr. Agustin Lobo
>> Institut de Ciencies de la Terra "Jaume Almera" (CSIC)
>> LLuis Sole Sabaris s/n
>> 08028 Barcelona
>> Spain
>> Tel. 34 934095410
>> Fax. 34 934110012
>> email: Agustin.Lobo at ija.csic.es
>> http://www.ija.csic.es/gt/obster
>>
>
--
Dr. Agustin Lobo
Institut de Ciencies de la Terra "Jaume Almera" (CSIC)
LLuis Sole Sabaris s/n
08028 Barcelona
Spain
Tel. 34 934095410
Fax. 34 934110012
email: Agustin.Lobo at ija.csic.es
http://www.ija.csic.es/gt/obster
More information about the R-help
mailing list