On Mon, Apr 18, 2011 at 22:20, Paul Menzel wrote:
Dear ConTeXt folks,
I need to plot some random walks similar to [1], but for example I need to emphasize certain sections of the plot and put labels and notes in there.
Could you recommend a tool to easily accomplish that goal with easily. I guess it can be done with any of those as seen by the demos [2][3].
I only have little experience using Gnuplot and I have never used Asymptote or MetaFun. These three seem to be well integrated with ConTeXt and I guess in the end I could just create the image files and include these in to my ConTeXt source.
The only downside of Asymptote I found so far is, that there is no mailing list.
Below you have an example done in metapost/metafun (which integrates well with ConTeXt). The downside of metapost is that you have to do all the labels and axis drawing more or less manually, while gnuplot will take care of drawing axes and properly adjusting the range etc. On the other hand metapost might be quite powerful for geometrically complex graphics. If you use gnuplot, you might need to precompute the points for the random walk (it supports random numbers, but I'm not sure if you can calculate sums), while metapost can do some reasonable calculations on the fly. For 2D graphics asymptote doesn't bring you much. Yet another alternative is TikZ and pgfplots (similar to metapost, more library functions ready to draw all kinds of graphics, but less powerful math engine that in metapost). \setupcolors [state=start] \starttext \startMPpage save wx, wy; wx = 15cm; wy = 10cm; draw unitsquare shifted (0,-0.5) xyscaled (wx,wy); save val; numeric val; save tmp; numeric tmp; save p; path p; save c; color c[]; c[1] = red; c[2] = .5[red,yellow]; c[3] = .6green; c[4] = blue; c[5] = .4white; vardef newval = val := val + floor(uniformdeviate(2))*2-1; (val) enddef; for n=1 upto 5: val := 0; draw (0,0) for i=0 upto 100: -- (0.01*i*wx,0.025*newval*wy) endfor withcolor c[n]; endfor for i=0 step 20 until 100: label.bot(decimal(i), (0.01*i*wx,-.5*wy)); endfor; for i=-20 step 5 until 20: label.lft(decimal(i), (0,0.025*i*wy)); endfor; \stopMPpage \stoptext