How to set default parameters for a graphical device? : <p>I like to read white on black. So, in R I would do something along the lines of:</p>

<pre><code>par (bg = "black")
par (fg = "ivory1")
</code></pre>

<p>I would like these options to be set by default. However, one does not simply write these lines in <code>.Rprofile</code> because, as I understand, at the time it gets executed, the graphical device is not yet initialized. Rather, as suggested in <a href="https://stackoverflow.com/a/13480570/2108477">another answer</a>, one should re-assign <code>options()$device</code> to include the necessary option setting. I did not have success in that.</p>

<p>&nbsp;</p>

<p>This is what I tried:</p>

<p><em><code>~/.Rprofile</code></em></p>

<pre><code>f_device &lt;- options()$device

blackdevice &lt;- function (...) {

    f_device(...)

    par (bg       = "black")
    par (fg       = "ivory1")
}

options (device = blackdevice)
</code></pre>

<p>The idea here is to save the original <code>device</code> function to another variable, and then call it from my new <code>device</code> function. What I get is:</p>

<pre><code>Error in f_device(...) : could not find function "f_device"
</code></pre>

<p>— At the time I run <code>plot (something)</code>.</p>

<p>&nbsp;</p>

<p>Another idea I had is to go like that:</p>

<p><em><code>~/.Rprofile</code></em></p>

<pre><code>.First &lt;- function () {

    options(f_device = options()$device)

    blackdevice &lt;- function (...) {

        options()$f_device(...)

        par (bg       = "black")
        par (fg       = "ivory1")
    }

    options (device = blackdevice)
}
</code></pre>

<p>— Assigning the original <code>device</code> someplace else in <code>options</code>. But this leads to:</p>

<pre><code>Error in (function (...)  : attempt to apply non-function
</code></pre>

<p>&nbsp;</p>

<p>I'm out of ideas. Can you help me figure this out?</p>
