Filled Line Chart

Version 1.0 (472 ko) par Alexis Wang
Plots a line chart with a filled gradient using explicit triangulation for optimization.
47 téléchargements
Mise à jour 2 sept. 2022

Filled Line Chart

View Filled Line Chart on File Exchange

Version: 1.0

Plots a line chart with a filled gradient using explicit triangulation for optimization.

Example of Filled Line Chart by plotting a sine curve.

Example of Filled Line Chart by plotting a sine curve with the triangulation shown.

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. Use f 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 representing m different lines, each assuming to share the same n 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 (scalar 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 LegendVisible is not on, then the labels will not appear.
  • Optimized (scalar 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).
  • ShowTriangulation (scalar 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

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. Extrait(e) le .

Compatibilité avec les versions de MATLAB
Créé avec R2022a
Compatible avec les versions R2021a à R2022a
Plateformes compatibles
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Publié le Notes de version
1.0

Pour consulter ou signaler des problèmes liés à ce module complémentaire GitHub, accédez au dépôt GitHub.
Pour consulter ou signaler des problèmes liés à ce module complémentaire GitHub, accédez au dépôt GitHub.