<html lang="en"> <head> <title>Managing Default Properties - GNU Octave</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="GNU Octave"> <meta name="generator" content="makeinfo 4.13"> <link title="Top" rel="start" href="index.html#Top"> <link rel="up" href="Graphics-Data-Structures.html#Graphics-Data-Structures" title="Graphics Data Structures"> <link rel="prev" href="Searching-Properties.html#Searching-Properties" title="Searching Properties"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } --></style> </head> <body> <div class="node"> <a name="Managing-Default-Properties"></a> <p> Previous: <a rel="previous" accesskey="p" href="Searching-Properties.html#Searching-Properties">Searching Properties</a>, Up: <a rel="up" accesskey="u" href="Graphics-Data-Structures.html#Graphics-Data-Structures">Graphics Data Structures</a> <hr> </div> <h4 class="subsection">15.3.5 Managing Default Properties</h4> <p><a name="index-default-graphics-properties-1538"></a><a name="index-graphics-properties_002c-default-1539"></a> Object properties have two classes of default values, <dfn>factory defaults</dfn> (the initial values) and <dfn>user-defined defaults</dfn>, which may override the factory defaults. <p>Although default values may be set for any object, they are set in parent objects and apply to child objects, of the specified object type. For example, setting the default <code>color</code> property of <code>line</code> objects to "green", for the <code>root</code> object, will result in all <code>line</code> objects inheriting the <code>color</code> "green" as the default value. <pre class="example"> set (0, "defaultlinecolor", "green"); </pre> <p class="noindent">sets the default line color for all objects. The rule for constructing the property name to set a default value is <pre class="example"> default + <var>object-type</var> + <var>property-name</var> </pre> <p>This rule can lead to some strange looking names, for example <code>defaultlinelinewidth"</code> specifies the default <code>linewidth</code> property for <code>line</code> objects. <p>The example above used the root figure object, 0, so the default property value will apply to all line objects. However, default values are hierarchical, so defaults set in a figure objects override those set in the root figure object. Likewise, defaults set in axes objects override those set in figure or root figure objects. For example, <pre class="example"> subplot (2, 1, 1); set (0, "defaultlinecolor", "red"); set (1, "defaultlinecolor", "green"); set (gca (), "defaultlinecolor", "blue"); line (1:10, rand (1, 10)); subplot (2, 1, 2); line (1:10, rand (1, 10)); figure (2) line (1:10, rand (1, 10)); </pre> <p class="noindent">produces two figures. The line in first subplot window of the first figure is blue because it inherits its color from its parent axes object. The line in the second subplot window of the first figure is green because it inherits its color from its parent figure object. The line in the second figure window is red because it inherits its color from the global root figure parent object. <p>To remove a user-defined default setting, set the default property to the value <code>"remove"</code>. For example, <pre class="example"> set (gca (), "defaultlinecolor", "remove"); </pre> <p class="noindent">removes the user-defined default line color setting from the current axes object. To quickly remove all user-defined defaults use the <code>reset</code> function. <!-- reset src/graphics.cc --> <p><a name="doc_002dreset"></a> <div class="defun"> — Built-in Function: <b>reset</b> (<var>h, property</var>)<var><a name="index-reset-1540"></a></var><br> <blockquote><p>Remove any defaults set for the handle <var>h</var>. The default figure properties of "position", "units", "windowstyle" and "paperunits" and the default axes properties of "position" and "units" are not reset. </p></blockquote></div> <p>Getting the <code>"default"</code> property of an object returns a list of user-defined defaults set for the object. For example, <pre class="example"> get (gca (), "default"); </pre> <p class="noindent">returns a list of user-defined default values for the current axes object. <p>Factory default values are stored in the root figure object. The command <pre class="example"> get (0, "factory"); </pre> <p class="noindent">returns a list of factory defaults. </body></html>