Difference between revisions of "Pre-Emptive Formatting"
m |
m |
||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | Many settings can be made before a plot is constructed. For instance, one can select the colour that a line will be before the line is drawn. | ||
+ | |||
==General Syntax== | ==General Syntax== | ||
+ | |||
+ | <pre>>> property(value1, value2, ...)</pre> | ||
+ | |||
+ | This will set the property to the values selected. When more than one value is chosen, the values are used on plots in the order they are input so that | ||
+ | |||
+ | <pre>>> property(value1, value2, value3) | ||
+ | >> dl(w) | ||
+ | >> pl(w2) | ||
+ | >> pm(w3) | ||
+ | >> pe(w4)</pre> | ||
+ | |||
+ | is equivilent to | ||
+ | |||
+ | <pre>>> property(value1) | ||
+ | >> dl(w) | ||
+ | >> property(value2) | ||
+ | >> pl(w2) | ||
+ | >> property(value3) | ||
+ | >> pm(w3) | ||
+ | >> property(value1) | ||
+ | >> pe(w4)</pre> | ||
+ | |||
==Colors== | ==Colors== | ||
+ | To set the colour of markers and lines in plots use the command | ||
+ | |||
+ | <pre>>> acolor('color')</pre> | ||
+ | |||
+ | where 'color' may be a standard matlab character: | ||
+ | |||
+ | 'r', 'g', 'b', 'c', 'm', 'y', 'k', 'w' | ||
+ | |||
+ | or any of the colour names | ||
+ | |||
+ | 'red', 'geen', 'blue', 'cyan', 'magenta', 'yellow', 'black', 'white' | ||
+ | |||
==Lines== | ==Lines== | ||
+ | |||
+ | To set the width and type of line use the command | ||
+ | |||
+ | <pre>>> aline('linestyle') | ||
+ | >> aline(linewidth) | ||
+ | >> aline('linestyle', linewidth)</pre> | ||
+ | |||
+ | where linewidth is a number. Valid linestyles are given [[User Reference#Valid Linestyles|here]]. | ||
+ | |||
==Markers== | ==Markers== | ||
+ | |||
+ | To set the marker style and width use the command | ||
+ | |||
+ | <pre>>> amark('marker style') | ||
+ | >> amark(markerwidth) | ||
+ | >> amark('marker style', markerwidth</pre> | ||
+ | |||
+ | where markerwidth is a number. Valid marker styles are given [[User Reference#Valid Marker Styles|here]]. | ||
+ | |||
+ | |||
+ | ==Using Name Tags== | ||
+ | |||
+ | When a plot is made, it may be given a name and a tag. If you only want to change the properties of plots with a particular name and tag then use the syntax | ||
+ | |||
+ | <pre>>> property(name, tag, value1, value2, value3,...)</pre> | ||
+ | |||
+ | now only plots that are made with the command | ||
+ | |||
+ | <pre>>> plottype(w, name, tag)</pre> | ||
+ | |||
+ | will have the properties that have been set. All other plots will retain whatever global properties were set previously. | ||
+ | |||
+ | See [[Using Default Properties and Name Tags]] for further information. | ||
+ | |||
+ | |||
+ | ==Examples== | ||
+ | |||
+ | If the following properties are set | ||
+ | |||
+ | <pre>>> acolor('red', 'green', 'blue') | ||
+ | >> amark('o', 3, '*', 4, 'o', 1) | ||
+ | >> aline('--', 5, '.-', 2) | ||
+ | >> amark('toby', 'plot', 2)</pre> | ||
+ | |||
+ | then the following would happen under various circumstances | ||
+ | |||
+ | |||
+ | {| {{Tablestyle}} | ||
+ | |- | ||
+ | ! {{Headcellstyle}} | Commands Given | ||
+ | ! {{Headcellstyle}} | Result | ||
+ | ! {{Headcellstyle}} | Reason | ||
+ | |- | ||
+ | |>> [[Plot Commands#One Dimensional Plots|dl]](w1) | ||
+ | | Line plot of w1 in red, style '--', size 5 | ||
+ | | First plot is set to red, '--' size 5 | ||
+ | |- | ||
+ | |>> [[Plot Commands#Overplots|pl]](w2) | ||
+ | |Line over plot of w2 in green, style '.-', size 5 | ||
+ | |Follows next color and line properties | ||
+ | |- | ||
+ | |>> [[Plot Commands#Overplots|pm]](w2,'color','red') | ||
+ | |Marker over plot of w2 in red, style '0' size 3 | ||
+ | |Properties set at plot level over-ride pre-determined defaults, this is the first time a marker is used on this plot so it takes the first value | ||
+ | |- | ||
+ | |>> [[Plot Commands#One Dimensional Plots|dl]](w1,'name','Dickon plot','tag','') | ||
+ | |New figure line plot of w1 in red | ||
+ | |Name tag given, so new window and uses the first colour | ||
+ | |} | ||
+ | |||
+ | {| {{Tablestyle}} | ||
+ | |- | ||
+ | ! {{Headcellstyle}} | Commands Given | ||
+ | ! {{Headcellstyle}} | Result | ||
+ | ! {{Headcellstyle}} | Reason | ||
+ | |- | ||
+ | |>> [[Plot Commands#One Dimensional Plots|dm]](w1,'name','toby','tag','plot') | ||
+ | | Marker plot of w1 style 'o', size 2, colour red | ||
+ | | The marker styles were set globally, so these are used, however there was a specific marker size set for plots with the name-tag toby plot so this is used. Colours are used from the globally set values. | ||
+ | |- | ||
+ | |>> [[Plot Commands#Overplots|dm]](w2,'name','toby','tag','plot') | ||
+ | | Marker plot of w2 style 'o', size 2, colour red | ||
+ | | This is a new plot, so starts at the first values. | ||
+ | |- | ||
+ | |>> [[Plot Commands#Overplots|pm]](w1,'name','toby','tag','plot') | ||
+ | |Marker over plot of w1 in green, style '*' size 2 | ||
+ | |The next set of values is used for colour and style, but all toby plots must have marker size 2. | ||
+ | |- | ||
+ | |>> [[Plot Commands#One Dimensional Plots|pm]](w1,'name','toby','tag','plot') | ||
+ | |Marker overplot of w1 in blue, style 'o' size 2 | ||
+ | |The style has now cycled around to it's first value. | ||
+ | |} |
Latest revision as of 15:04, 19 March 2008
Many settings can be made before a plot is constructed. For instance, one can select the colour that a line will be before the line is drawn.
General Syntax
>> property(value1, value2, ...)
This will set the property to the values selected. When more than one value is chosen, the values are used on plots in the order they are input so that
>> property(value1, value2, value3) >> dl(w) >> pl(w2) >> pm(w3) >> pe(w4)
is equivilent to
>> property(value1) >> dl(w) >> property(value2) >> pl(w2) >> property(value3) >> pm(w3) >> property(value1) >> pe(w4)
Colors
To set the colour of markers and lines in plots use the command
>> acolor('color')
where 'color' may be a standard matlab character:
'r', 'g', 'b', 'c', 'm', 'y', 'k', 'w'
or any of the colour names
'red', 'geen', 'blue', 'cyan', 'magenta', 'yellow', 'black', 'white'
Lines
To set the width and type of line use the command
>> aline('linestyle') >> aline(linewidth) >> aline('linestyle', linewidth)
where linewidth is a number. Valid linestyles are given here.
Markers
To set the marker style and width use the command
>> amark('marker style') >> amark(markerwidth) >> amark('marker style', markerwidth
where markerwidth is a number. Valid marker styles are given here.
Using Name Tags
When a plot is made, it may be given a name and a tag. If you only want to change the properties of plots with a particular name and tag then use the syntax
>> property(name, tag, value1, value2, value3,...)
now only plots that are made with the command
>> plottype(w, name, tag)
will have the properties that have been set. All other plots will retain whatever global properties were set previously.
See Using Default Properties and Name Tags for further information.
Examples
If the following properties are set
>> acolor('red', 'green', 'blue') >> amark('o', 3, '*', 4, 'o', 1) >> aline('--', 5, '.-', 2) >> amark('toby', 'plot', 2)
then the following would happen under various circumstances
Commands Given | Result | Reason |
---|---|---|
>> dl(w1) | Line plot of w1 in red, style '--', size 5 | First plot is set to red, '--' size 5 |
>> pl(w2) | Line over plot of w2 in green, style '.-', size 5 | Follows next color and line properties |
>> pm(w2,'color','red') | Marker over plot of w2 in red, style '0' size 3 | Properties set at plot level over-ride pre-determined defaults, this is the first time a marker is used on this plot so it takes the first value |
>> dl(w1,'name','Dickon plot','tag',) | New figure line plot of w1 in red | Name tag given, so new window and uses the first colour |
Commands Given | Result | Reason |
---|---|---|
>> dm(w1,'name','toby','tag','plot') | Marker plot of w1 style 'o', size 2, colour red | The marker styles were set globally, so these are used, however there was a specific marker size set for plots with the name-tag toby plot so this is used. Colours are used from the globally set values. |
>> dm(w2,'name','toby','tag','plot') | Marker plot of w2 style 'o', size 2, colour red | This is a new plot, so starts at the first values. |
>> pm(w1,'name','toby','tag','plot') | Marker over plot of w1 in green, style '*' size 2 | The next set of values is used for colour and style, but all toby plots must have marker size 2. |
>> pm(w1,'name','toby','tag','plot') | Marker overplot of w1 in blue, style 'o' size 2 | The style has now cycled around to it's first value. |