Note that there are some explanatory texts on larger screens.

plurals
  1. POR: update plot [xy]lims with new points() or lines() additions?
    primarykey
    data
    text
    <p><strong><em>Background:</em></strong> </p> <p>I'm running a Monte Carlo simulation to show that a particular process (a cumulative mean) does <strong>not</strong> converge over time, and often diverges wildly in simulation (the expectation of the random variable = infinity). I want to plot about 10 of these simulations on a line chart, where the x axis has the iteration number, and the y axis has the cumulative mean up to that point.</p> <p><strong><em>Here's my problem:</em></strong></p> <p>I'll run the first simulation (each sim. having 10,000 iterations), and build the main plot based on its current range. But often one of the simulations will have a range a few orders of magnitude large than the first one, so the plot flies outside of the original range. So, <strong>is there any way to dynamically update the ylim or xlim of a plot upon adding a new set of points or lines?</strong></p> <p>I can think of two <strong>workarounds</strong> for this: 1. store each simulation, then pick the one with the largest range, and build the base graph off of that (not elegant, and I'd have to store a lot of data in memory, but would probably be laptop-friendly <strong>[[EDIT: as Marek points out, this is not a memory-intense example, but if you know of a nice solution that'd support far more iterations such that it becomes an issue (think high dimensional walks that require much, much larger MC samples for convergence) then jump right in]]</strong>) 2. find a seed that appears to build a nice looking version of it, and set the ylim manually, which would make the demonstration reproducible.</p> <p>Naturally I'm holding out for something more elegant than my workarounds. Hoping this isn't too pedestrian a problem, since I imagine it's not uncommon with simulations in R. Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload