LineData
Create a line data plot.
Syntax
model.result(<pgtag>).create(<ftag>,"LineData");
model.result(<pgtag>).feature(<ftag>).set(property, <value>);
model.result(<pgtag>).feature(<ftag>).run();
Description
model.result(<pgtag>).create(<ftag>,"LineData") creates a line data plot feature named <ftag> belonging to the 2D or 3D plot group <pgtag>.
Line data plots are used to visualize raw point data given as points, elements, and colors as line segments (see the examples below). Line data plots can be added to 2D and 3D plot groups.
The following properties are available:
custom | black | blue | cyan | gray | green | magenta | red | white | yellow
custom | black | blue | cyan | gray | green |magenta | red | white | yellow
colortable | uniform | gradient
on | off
Whether to show color legend when coloring is set to colortable.
The color table to use when coloring is set to colortable. See Color Tables for a list of color tables.
on | off
Whether to reverse to color table or color gradient when coloring is set to colortable or gradient.
on | off
Whether to symmetrize the color range around 0 when coloring is set to colortable or gradient.
{1,0,0} or last used color.
The uniform color to use. Active when bottomcolor is set to custom.
{1,0,0} or last used color.
{1,0,0} or last used color.
The uniform color to use. Active when topcolor is set to custom.
on | off
Whether to use the manual color range specified in rangecolormin and rangecolormax. The color range specifies the minimum and maxim value in the plotted colors. Default is the minimum and maximum data values.
on | off
Whether to use the manual data range specified in rangedatamin and rangedatamax. Values outside the data range are not plotted.
The title to use when titletype is manual.
auto | manual | none
auto if the title contribution should be computed automatically. manual if the manual title contribution should be used (the title property). none if no title contribution should be used.
custom | black | blue | cyan | gray | green | magenta | red | white | yellow
Attributes
None.
Examples
A method for creating a line data plot in 2D for data representing a sine curve (x, sin(x)):
Code for Use with Java
ResultFeature pg = m.result().create("pg1", 2);
ResultFeature plot = pg.create("line1", "LineData");
int N = 100;
double[][] p = new double[2][N];
int[][] t = new int[2][N - 1];
double[] color = new double[N];
for (int i = 0; i < N; i++) {
double x = 4 * Math.PI * i / N;
p[0][i] = x;
p[1][i] = Math.sin(x);
if (i > 0) {
t[0][i - 1] = i - 1;
t[1][i - 1] = i;
}
}
plot.set("pointdata", p)
.set("elementdata", t)
.set("colordata", color);
plot.run();
Code for Use with MATLAB
This variant, for use with MATLAB®, sets a fixed blue color for the line and plots it:
import com.comsol.model.util.*
model = ModelUtil.create('Model');
pg = model.result.create('pg', 3);
pl = pg.create('line', 'LineData');
x = 0:100;
y = [sqrt(x); sin(x); cos(x)];
t = [1:99; 2:100];
pl.set('pointdata', y);
pl.set('elementdata', t);
pl.set('color', 'blue')
mphplot(model, 'pg')
A method for creating a line data plot in 3D for data representing a curve (x, x1.3, x1.6):
Code for Use with Java
pg = m.result().create("pg2", 3);
plot = pg.create("line1", "LineData");
p = new double[3][N];
t = new int[2][N - 1];
color = new double[N];
for (int i = 0; i < N; i++) {
p[0][i] = i;
p[1][i] = Math.pow(i, 1.3);
p[2][i] = Math.pow(i, 1.6);
if (i > 0) {
t[0][i - 1] = i - 1;
t[1][i - 1] = i;
}
}
plot.set("pointdata", p)
.set("elementdata", t)
.set("colordata", color);
plot.run();
See Also
AnnotationData, ArrowData, PointData, SurfaceData, TubeData