Filled Line Chart
Filled Line Chart
Version: 1.0
Plots a line chart with a filled gradient using explicit triangulation for optimization.
Syntax
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. Usef
to modify properties of the chart after creating it.
This information is also available if you call help filledLineChart
.
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 representingm
different lines, each assuming to share the samen
x-coordinates. -
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. -
Grid
('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. -
LineStyle
('-', '--', ':', or '-.'
) - the style of the line. Note that if there are multiple lines, this property will apply to all of them. -
LegendVisible
(scalarmatlab.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 ifLegendVisible
is not on, then the labels will not appear. -
Optimized
(scalarmatlab.lang.OnOffSwitchState
) - specifies whether to use the optimized algorithm (with triangulation) or the unoptimized one (drawing out the line and the area underneath it). -
ShowTriangulation
(scalarmatlab.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
Open the 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 ShowTriangulation
property.
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";
Citation pour cette source
Alexis Wang (2024). Filled Line Chart (https://github.com/MATLAB-Graphics-and-App-Building/filled-line-chart/releases/tag/v1.0), GitHub. Récupéré le .
Compatibilité avec les versions de MATLAB
Plateformes compatibles
Windows macOS LinuxTags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Découvrir Live Editor
Créez des scripts avec du code, des résultats et du texte formaté dans un même document exécutable.
Version | Publié le | Notes de version | |
---|---|---|---|
1.0 |