comparison libinterp/corefcn/graphics.cc @ 31786:4ccdb13c160a stable

doc: Add examples for first 3 calling forms of set() * graphics.cc: Add examples for first 3 calling forms of set().
author Rik <rik@octave.org>
date Fri, 27 Jan 2023 14:08:38 -0800
parents becfd7914178
children 53b2eb3cb06a b482ed13ac1a
comparison
equal deleted inserted replaced
31784:becfd7914178 31786:4ccdb13c160a
12904 There are three ways to give the property names and values: 12904 There are three ways to give the property names and values:
12905 12905
12906 @itemize 12906 @itemize
12907 @item as a comma separated list of @var{property}, @var{value} pairs 12907 @item as a comma separated list of @var{property}, @var{value} pairs
12908 12908
12909 Here, each @var{property} is a string containing the property name, each 12909 Each @var{property} is a string containing the property name, each @var{value}
12910 @var{value} is a value of the appropriate type for the property. 12910 is a value of the appropriate type for the property. When there are multiple
12911 handles in @var{h}, each one is assigned the same @var{value}. For example:
12912
12913 @example
12914 @group
12915 h = plot ([0, 1]);
12916 set (h, 'color', 'green');
12917 @end group
12918 @end example
12911 12919
12912 @item as a cell array of strings @var{properties} containing property names 12920 @item as a cell array of strings @var{properties} containing property names
12913 and a cell array @var{values} containing property values. 12921 and a cell array @var{values} containing property values.
12914 12922
12915 In this case, the number of columns of @var{values} must match the number of 12923 In this case, the number of columns of @var{values} must match the number of
12916 elements in @var{properties}. The first column of @var{values} contains 12924 elements in @var{properties}. The first column of @var{values} contains
12917 values for the first entry in @var{properties}, etc. The number of rows of 12925 values for the first entry in @var{properties}, etc. The number of rows of
12918 @var{values} must be 1 or match the number of elements of @var{h}. In the 12926 @var{values} must be 1 or match the number of elements of @var{h}. In the
12919 first case, each handle in @var{h} will be assigned the same values. In the 12927 first case, each handle in @var{h} will be assigned the same values. In the
12920 latter case, the first handle in @var{h} will be assigned the values from 12928 second case, the first handle in @var{h} will be assigned the values from
12921 the first row of @var{values} and so on. 12929 the first row of @var{values} and so on. For example:
12922 12930
12923 @item as a structure array @var{pv} 12931 @example
12924 12932 @group
12925 Here, the field names of @var{pv} represent the property names, and the 12933 h = plot ([0, 1; 1, 0]);
12926 field values give the property values. In contrast to the previous case, 12934 set (h, @{'color'@}, @{'green'; 'red'@});
12927 all elements of @var{pv} will be set in all handles in @var{h} independent 12935 @end group
12928 of the dimensions of @var{pv}. 12936 @end example
12937
12938 @item as a structure @var{pv}
12939
12940 This is the same as the first case where the field names of @var{pv} represent
12941 the property names, and the field values give the property values. As with
12942 the first case, it is only possible to set one value for a property which will
12943 be applied to all handles in @var{h}. For example:
12944
12945 @example
12946 @group
12947 h = plot ([0, 1]);
12948 props.color = 'green';
12949 set (h, props);
12950 @end group
12951 @end example
12929 @end itemize 12952 @end itemize
12930 12953
12931 @code{set} is also used to query the list of values a named property will 12954 @code{set} is also used to query the list of values a named property will
12932 take. @code{@var{clist} = set (@var{h}, "property")} will return the list 12955 take. @code{@var{clist} = set (@var{h}, "property")} will return the list
12933 of possible values for @qcode{"property"} in the cell list @var{clist}. 12956 of possible values for @qcode{"property"} in the cell list @var{clist}.