Filled Line Chart
Updated Fri, 02 Sep 2022 16:15:14 +0000
Filled Line Chart
Plots a line chart with a filled gradient using explicit triangulation for optimization.
Rather than depending on patch's algorithm to triangulize the object for rendering, it is more efficient and scalable to explicitly provide it. See the
performanceTest.m file for more info.
filledLineChart(XData, YData)- creates one or more lines each with their own gradient using an optimized algorithm. Each column of YData represents a new line.
filledLineChart(_, Name, Value)- specifies additional options for the chart using one or more name-value pair arguments. Specify the options after all other input arguments.
filledLineChart(target, _)- plots into target instead of GCF.
f = filledLineChart(_)- returns the filledLineChart object. Use
fto modify properties of the chart after creating it.
This information is also available if you call
Name-Value Pair Arguments/Properties
XData(n x 1 numeric vector) - the x-coordinates of the line, not including NaNs.
YData(n x m numeric non-negative vector) - the y-coordinates of the line, not including NaNs. Each column is assumed to be a new line representing
mdifferent lines, each assuming to share the same
Title(1 x n char vector) - the title of the chart.
Subtitle(1 x n char vector) - the subtitle of the chart.
XLabel(1 x n char vector) - the label of the x-axis.
YLabel(1 x n char vector) - the label of the y-axis.
ColorOrder(n x 3 RGB triplets)- the color order used for the patch and line objects. Each line and its gradient will have the same color based on the color order.
'on', 'off', 'rows', or 'columns') - specifies which major gridlines are visible.
LineWidth(double) - the width of the line. Note that if there are multiple lines, this property will apply to all of them.
'-', '--', ':', or '-.') - the style of the line. Note that if there are multiple lines, this property will apply to all of them.
matlab.lang.OnOffSwitchState) - specifies whether to have a legend or not.
LegendLabels(1 x m char vector) - the labels of the legend for each line. Note if
LegendVisibleis not on, then the labels will not appear.
matlab.lang.OnOffSwitchState) - specifies whether to use the optimized algorithm (with triangulation) or the unoptimized one (drawing out the line and the area underneath it).
matlab.lang.OnOffSwitchState) - species whether to show the explicit triangulation by setting the edge color of the patch object to black. If the chart was plotted using the unoptimized algorithm, no triangulation was used so it will not appear, even if this property is on.
example.mlx file to view more examples.
Graph a sine curve with a filled gradient.
n = 10; x = 1:n; y = 5*sin(linspace(0,4*pi,n)) + 5; f = filledLineChart(x,y); f.Title = "Sine Curve"; f.Subtitle = "n=10"; f.XLabel = "X-Values"; f.YLabel = "Y-Values"; f.LineStyle = '--';
Display the triangulation using the
f.ShowTriangulation = 'on';
To plot multiple lines, a sine and cosine curve, provide the new YData as two columns.
n = 100; x = 1:n; y = 5*sin(linspace(0,4*pi,n)) + 5; y2 = 5*cos(linspace(0,4*pi,n)) + 5; g = filledLineChart(x,[y' y2'], 'LegendVisible', true, 'LegendLabels', ["sin(x)" "cos(x)"]); g.Title = "Sine and Cosine Curve"; g.Subtitle = "n=100"; g.XLabel = "X-Values"; g.YLabel = "Y-Values";
Alexis Wang (2023). Filled Line Chart (https://github.com/MATLAB-Graphics-and-App-Building/filled-line-chart/releases/tag/v1.0), GitHub. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!