getLayout
Class: matlab.graphics.chartcontainer.ChartContainer
Namespace: matlab.graphics.chartcontainer
Syntax
tcl = getLayout(obj)
Description
returns
the tiled chart layout for a chart object that inherits from the
tcl
= getLayout(obj
)matlab.graphics.chartcontainer.ChartContainer
base class.
Input Arguments
obj
— Object of the class
chart object
Object of the class that inherits from the
matlab.graphics.chartcontainer.ChartContainer
base class.
Output Arguments
tcl
— Tiled chart layout object
TiledChartLayout
object
TiledChartLayout
object. Use tcl
when you are
developing a chart that contains a polar plot, a geographic plot, or a tiling of
multiple plots. You can configure certain aspects of the layout, such as the number of
tiles, the location of each axes object, and the spacing between the tiles.
Examples
Display Side-by-Side Cartesian and Polar Plots
Define a class called CartPolarPlot
that plots data in Cartesian
and polar coordinates.
To define the class, create a file called CartPolarPlot.m
that
contains the following class definition with these features:
Three public properties:
XData
andYData
to store the coordinate data, andLineColor
to control the color of the linesFour private properties that store the two lines and axes objects
A
setup
method that configures the layout, creates the axes, and initializes the twoLine
objectsAn
update
method that updates theLine
objects when the user changes the value of one or more public properties
classdef CartPolarPlot < matlab.graphics.chartcontainer.ChartContainer properties XData (1,:) double = NaN YData (1,:) double = NaN LineColor (1,3) double {mustBeGreaterThanOrEqual(LineColor,0),... mustBeLessThanOrEqual(LineColor,1)} = [.5 0 1] end properties(Access = private,Transient,NonCopyable) CartesianLine (1,1) matlab.graphics.chart.primitive.Line PolarLine (1,1) matlab.graphics.chart.primitive.Line CartesianAx (1,1) matlab.graphics.axis.Axes PolarAx (1,1) matlab.graphics.axis.PolarAxes end methods(Access = protected) function setup(obj) % Get the layout and create the axes tcl = getLayout(obj); tcl.GridSize = [1 2]; obj.CartesianAx = axes(tcl); obj.PolarAx = polaraxes(tcl); % Move the polar axes to the second tile obj.PolarAx.Layout.Tile = 2; % Create the Cartesian and polar lines obj.CartesianLine = plot(obj.CartesianAx,NaN,NaN); obj.PolarLine = polarplot(obj.PolarAx,NaN,NaN); end function update(obj) % Update Cartesian line obj.CartesianLine.XData = obj.XData; obj.CartesianLine.YData = obj.YData; obj.CartesianLine.Color = obj.LineColor; % Update polar line obj.PolarLine.Color = obj.LineColor; obj.PolarLine.ThetaData = obj.XData; obj.PolarLine.RData = obj.YData; end end end
Next, create a set of x- and y-coordinates.
Then plot the coordinates by calling the CartPolarPlot
constructor
method with the 'XData'
and 'YData'
name-value
pair arguments.
x = 0:0.01:2*pi; y = sin(2*x).*cos(2*x); CartPolarPlot('XData',x,'YData',y);
Version History
Introduced in R2020a
See Also
Classes
Properties
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)