Contour plot matlab

Contour plot matlab DEFAULT

surfc

Main Content

  • Contour plot under surface plot

Syntax

Description

example

creates a three-dimensional surface plot with a contour plot underneath. A surface plot is a three-dimensional surface that has solid edge colors and solid face colors. The function plots the values in matrix as heights above a grid in the x-y plane defined by and . The color of the surface varies according to the heights specified by .

example

additionally specifies the surface color.

creates a surface and contour plot and uses the column and row indices of the elements in as the x- and y -coordinates.

additionally specifies the surface color.

plots into the axes specified by instead of the current axes. Specify the axes as the first input argument.

example

specifies surface properties using one or more name-value pair arguments. For example, creates a semitransparent surface.

example

returns a graphics array that includes the chart surface object and the contour object. Use to modify the surface and contour plots after they are created. For a list of properties, see Surface Properties and Contour Properties.

Examples

collapse all

Display Contour Plot Under Surface Plot

Create three matrices of the same size. Then plot them as a surface and display a contour plot under the surface plot. The surface uses for both height and color.

[X,Y] = meshgrid(1:0.5:10,1:20); Z = sin(X) + cos(Y); surfc(X,Y,Z)

Specify Colormap Colors for Surface and Contour Plot

Specify the colors for a surface and a contour plot by including a fourth matrix input, . The surface plot uses for height and for color. Specify the colors using a colormap, which uses single numbers to stand for colors on a spectrum. When you use a colormap, is the same size as . Add a color bar to the graph to show how the data values in correspond to the colors in the colormap.

[X,Y] = meshgrid(-3:.125:3); Z = peaks(X,Y); C = X.*Y; surfc(X,Y,Z,C) colorbar

Modify Appearance of Surface and Contour Plots

Create a blue surface plot with a contour plot underneath it by specifying the name-value pair with as the value. To allow further modifications, assign the graphics array containing the surface and contour objects to the variable .

[X,Y] = meshgrid(-5:.5:5); Z = Y.*sin(X) - X.*cos(Y); sc = surfc(X,Y,Z,'FaceColor','b');

Index into to access and modify properties of the surface and contour plots after they are created. The surface plot is accessible as and the contour plot as . For example, change the edge colors of the two plots by setting the properties.

sc(1).EdgeColor = 'r'; sc(2).EdgeColor = 'b';

Change Location of Contour Lines

The contour lines appear at the minimum z-level by default, but you can change the location by setting the property.

Display the data set as a surface plot with the contours at the minimum z-level. Specify a return argument when you call the function so that you can access the object.

Z = peaks; sc = surfc(Z);

Get the current axes and extend the upper limit of the z-axis to . Then move the contours to the maximum z-level.

ax = gca; ax.ZLim(2) = 15; sc(2).ZLocation = 'zmax';

Input Arguments

collapse all

x-coordinates
matrix | vector

x-coordinates, specified as a matrix the same size as , or as a vector with length , where . If you do not specify values for and , uses the vectors and .

When is a matrix, the values must be strictly increasing or decreasing along one dimension and remain constant along the other dimension. The dimension that varies must be the opposite of the dimension that varies in . You can use the function to create and matrices.

When is a vector, the values must be strictly increasing or decreasing.

The properties of the surface and contour objects store the x-coordinates.

Example:

Example:

Example:

Data Types: | | | | | | | | | |

y-coordinates
matrix | vector

y-coordinates, specified as a matrix the same size as or as a vector with length , where . If you do not specify values for and , uses the vectors and .

When is a matrix, the values must be strictly increasing or decreasing along one dimension and remain constant along the other dimension. The dimension that varies must be the opposite of the dimension that varies in . You can use the function to create and matrices.

When is a vector, the values must be strictly increasing or decreasing.

The properties of the surface and contour objects store the y-coordinates.

Example:

Example:

Example:

Data Types: | | | | | | | | | |

z-coordinates
matrix

z-coordinates, specified as a matrix. must have at least two rows and two columns.

specifies the height of the surface plot at each x-y coordinate. If you do not specify the colors, then also specifies the surface colors.

The properties of the surface and contour objects store the z-coordinates.

Example:

Example:

Data Types: | | | | | | | | | |

— Color array
matrix | -by--by- array of RGB triplets

Color array, specified as an -by- matrix of colormap indices or as an -by--by- array of RGB triplets, where is -by-.

  • To use colormap colors, specify as a matrix. For each grid point on the surface, indicates a color in the colormap. The property of the surface object controls how the values in correspond to colors in the colormap.

  • To use truecolor colors, specify as an array of RGB triplets.

For more information, see Differences Between Colormaps and Truecolor.

The property of the surface object stores the color array. For additional control over the surface coloring, use the and properties.

— Axes to plot in
axes object

Axes to plot in, specified as an object. If you do not specify the axes, then plots into the current axes.

Name-Value Arguments

Specify optional comma-separated pairs of arguments. is the argument name and is the corresponding value. must appear inside quotes. You can specify several name and value pair arguments in any order as .

Example: creates a semitransparent surface with no edges drawn.

Note

The properties listed here are only a subset. For a full list, see Surface Properties.

— Edge line color
(default) | | | | RGB triplet | hexadecimal color code | | | | ...

Edge line color, specified as one of the values listed here. The default color of corresponds to black edges.

ValueDescription
Do not draw the edges.

Use a different color for each edge based on the values in the property. First you must specify the property as a matrix the same size as . The color value at the first vertex of each face (in the positive x and y directions) determines the color for the adjacent edges. You cannot use this value when the property is set to .

Use interpolated coloring for each edge based on the values in the property. First you must specify the property as a matrix the same size as . The color varies across each edge by linearly interpolating the color values at the vertices. You cannot use this value when the property is set to .

RGB triplet, hexadecimal color code, or color name

Use the specified color for all the edges. This option does not use the color values in the property.

RGB triplets and hexadecimal color codes are useful for specifying custom colors.

  • An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range ; for example,.

  • A hexadecimal color code is a character vector or a string scalar that starts with a hash symbol () followed by three or six hexadecimal digits, which can range from to . The values are not case sensitive. Thus, the color codes , , , and are equivalent.

Alternatively, you can specify some common colors by name. This table lists the named color options, the equivalent RGB triplets, and hexadecimal color codes.

Color NameShort NameRGB TripletHexadecimal Color CodeAppearance

Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB® uses in many types of plots.

RGB TripletHexadecimal Color CodeAppearance

— Line style
(default) | | | |

Line style, specified as one of the options listed in this table.

Line StyleDescriptionResulting Line
Solid line
Dashed line
Dotted line
Dash-dotted line
No lineNo line

— Face color
(default) | | | | RGB triplet | hexadecimal color code | | | | ...

Face color, specified as one of the values in this table.

ValueDescription

Use a different color for each face based on the values in the property. First you must specify the property as a matrix the same size as . The color value at the first vertex of each face (in the positive x and y directions) determines the color for the entire face. You cannot use this value when the property is set to .

Use interpolated coloring for each face based on the values in the property. First you must specify the property as a matrix the same size as . The color varies across each face by interpolating the color values at the vertices. You cannot use this value when the property is set to .

RGB triplet, hexadecimal color code, or color name

Use the specified color for all the faces. This option does not use the color values in the property.

Transform the color data in so that it conforms to the surface.
Do not draw the faces.

RGB triplets and hexadecimal color codes are useful for specifying custom colors.

  • An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range ; for example,.

  • A hexadecimal color code is a character vector or a string scalar that starts with a hash symbol () followed by three or six hexadecimal digits, which can range from to . The values are not case sensitive. Thus, the color codes , , , and are equivalent.

Alternatively, you can specify some common colors by name. This table lists the named color options, the equivalent RGB triplets, and hexadecimal color codes.

Color NameShort NameRGB TripletHexadecimal Color CodeAppearance

Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB uses in many types of plots.

RGB TripletHexadecimal Color CodeAppearance

— Face transparency
1 (default) | scalar in range | | |

Face transparency, specified as one of these values:

  • Scalar in range — Use uniform transparency across all the faces. A value of is fully opaque and is completely transparent. Values between and are semitransparent. This option does not use the transparency values in the property.

  • — Use a different transparency for each face based on the values in the property. The transparency value at the first vertex determines the transparency for the entire face. First you must specify the property as a matrix the same size as the property. The property also must be set to .

  • — Use interpolated transparency for each face based on the values in property. The transparency varies across each face by interpolating the values at the vertices. First you must specify the property as a matrix the same size as the property. The property also must be set to .

  • — Transform the data in so that it conforms to the surface.

— Effect of light objects on faces
(default) | |

Effect of light objects on faces, specified as one of these values:

  • — Apply light uniformly across each face. Use this value to view faceted objects.

  • — Vary the light across the faces. Calculate the light at the vertices and then linearly interpolate the light across the faces. Use this value to view curved surfaces.

  • — Do not apply light from light objects to the faces.

To add a light object to the axes, use the function.

Note

The value has been removed. Use instead.

Extended Capabilities

GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.

Usage notes and limitations:

  • This function accepts GPU arrays, but does not run on a GPU.

For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).

Distributed Arrays
Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.

Usage notes and limitations:

  • This function operates on distributed arrays, but executes in the client MATLAB.

For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).

See Also

Functions

Properties

Introduced before R2006a

You have a modified version of this example. Do you want to open this example with your edits?

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.

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: .

Select web site

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.

Contact your local office

Sours: https://www.mathworks.com/help/matlab/ref/surfc.html

contourf

Main Content

  • Filled contour plot

Description

example

creates a filled contour plot containing the isolines of matrix , where contains height values on the x-y plane. MATLAB® automatically selects the contour lines to display. The column and row indices of are the x and y coordinates in the plane, respectively.

specifies the x and y coordinates for the values in .

example

specifies the contour lines to display as the last argument in any of the previous syntaxes. Specify as a scalar value to display the contour lines at automatically chosen levels (heights). To draw the contour lines at specific heights, specify as a vector of monotonically increasing values. To draw the contours at one height (), specify as a two-element row vector .

example

specifies the style and color of the contour lines.

example

specifies additional options for the contour plot using one or more name-value pair arguments. Specify the options after all other input arguments. For a list of properties, see Contour Properties.

displays the contour plot in the target axes. Specify the axes as the first argument in any of the previous syntaxes.

returns the contour matrix , which contains the (x, y) coordinates of the vertices at each level.

example

returns the contour matrix and the contour object . Use to set properties after displaying the contour plot.

Examples

collapse all

Contours of Peaks Function

Define as a function of two variables. In this case, call the function to create . Then display a filled contour plot of , letting MATLAB® choose the contour levels.

Contours at Ten Levels

Define as a function of two variables, and . Then display contours at 10 levels of .

x = linspace(-2*pi,2*pi); y = linspace(0,4*pi); [X,Y] = meshgrid(x,y); Z = sin(X) + cos(Y); contourf(X,Y,Z,10)

Contours at Specific Levels with Labels

Define as a function of and . In this case, call the function to create , , and . Then display contours at levels and .

The white region corresponds to the heights less than . The purple region corresponds to heights between and . And the yellow region corresponds to heights that are greater than .

[X,Y,Z] = peaks(50); contourf(X,Y,Z,[2 3],'ShowText','on')

Contours at One Level

Define as a function of and . In this case, call the function to create , , and . Then display contours at .

[X,Y,Z] = peaks; contourf(X,Y,Z,[2 2])

Dashed Contour Lines

Create a contour plot, and specify the dashed line style.

[X,Y,Z] = peaks; contourf(X,Y,Z,'--')

Custom Line Width

Create a filled contour plot. Make the contour lines thicker by setting the property to .

Z = peaks; [M,c] = contourf(Z); c.LineWidth = 3;

Contours Over Discontinuous Surface

Insert values wherever there are discontinuities on a surface. The function does not draw contour lines in those regions.

Define matrix as a sampling of the function. Replace all values in column with values. Then plot the contours of the modified matrix.

Z = peaks; Z(:,26) = NaN; contourf(Z)

Input Arguments

collapse all

x-coordinates
matrix | vector

x-coordinates, specified as a matrix the same size as , or as a vector with length , where . The default value of is the vector .

When is a matrix, the values must be strictly increasing or decreasing along one dimension and remain constant along the other dimension. The dimension that varies must be the opposite of the dimension that varies in . You can use the function to create and matrices.

When is a vector, the values must be strictly increasing or decreasing.

Example:

Example:

Example:

The property of the object stores the x-coordinates.

Data Types: | | | | | | | | |

y-coordinates
matrix | vector

y-coordinates, specified as a matrix the same size as , or as a vector with length , where . The default value of is the vector .

When is a matrix, the values must be strictly increasing or decreasing along one dimension and remain constant along the other dimension. The dimension that varies must be the opposite of the dimension that varies in . You can use the function to create the and matrices.

When is a vector, the values must be strictly increasing or decreasing.

Example:

Example:

Example:

The property of the object stores the y-coordinates.

Data Types: | | | | | | | | |

z-coordinates
matrix

z-coordinates, specified as a matrix. This matrix must have at least two rows and two columns, and it must contain at least two different values.

Example:

The property of the object stores the z-coordinates.

Data Types: | | | | | | | | |

— Levels
scalar | vector

Contour levels, specified as a scalar whole number or a vector. Use this argument to control the number and location of the contour lines. When you do not specify the levels, the function chooses the levels automatically.

  • To draw contour lines at n automatically chosen heights, specify as the scalar value n.

  • To draw the contour lines at specific heights, specify as a vector of monotonically increasing values.

  • To draw contour lines at a single height , specify as a two-element row vector .

The function uses the current colormap to fill the spaces between the levels in the plot. The first color fills the space between the lowest level and the level above it. The last color corresponds to -values that are greater than the highest level in the plot. If contains values that are smaller than the lowest level displayed in the plot, the region between the lowest level and the smallest -value is white.

Example: draws contour lines at 10 automatically chosen heights on the function.

Example: draws contour lines at 3 specific heights on the function: , , and .

Example: draws contour lines to show where the height of the function is .

Data Types: | | | | | | | | |

— Line style and color
character vector | string scalar

Line style and color, specified as a character vector or string scalar containing characters and symbols. The characters and symbols can appear in any order. You can specify the line style, line color, or both. Marker symbols such as are ignored.

Example: is a green dashed line.

Line StyleDescriptionResulting Line
Solid line
Dashed line
Dotted line
Dash-dotted line
Color NameShort NameAppearance

— Target axes
object

Target axes, specified as an object. If you do not specify the axes, then plots into the current axes.

Name-Value Arguments

Specify optional comma-separated pairs of arguments. is the argument name and is the corresponding value. must appear inside quotes. You can specify several name and value pair arguments in any order as .

Example: displays the contour line labels.

Note

The properties listed here are only a subset. For a complete list, see Contour Properties.

— Contour line labels
(default) | on/off logical value

Contour line labels, specified as or , or as numeric or logical () or (). A value of is equivalent to , and is equivalent to . Thus, you can use the value of this property as a logical value. The value is stored as an on/off logical value of type .

  • — Display the height values along the contour lines.

  • — Do not label the contour lines.

— Line Width
(default) | positive value

Contour line width, specified as a positive value in points. One point equals 1/72 inch.

— Label spacing
(default) | scalar

Label spacing along the contour lines, specified as a scalar value in points, where one point is 1/72 inch. Use this property to control the number of contour labels along the contour lines. Smaller values produce more labels.

You must set the property to for the property to have an effect.

If you use the function to display the labels, then the property has no effect and the plot displays one label per line.

Output Arguments

collapse all

— Contour matrix
matrix

Contour matrix, returned as two-row matrix. This matrix contains the contour levels (heights) and the coordinates of the vertices at each level. The data is arranged sequentially in n sets of columns for n contour lines:

  • The first column in each set contains the contour level and the number of vertices at that level. The top number is the contour level, and the bottom number is the number of vertices.

  • Subsequent columns in the set are the (x, y) coordinates of the vertices. Each column represents an ordered pair. The top number is the x-coordinate, and the bottom number is the y-coordinate.

For example, here are the first few columns of the contour matrix :

The property of the object stores the contour matrix.

— Contour object
object

object. Use this object to set properties after displaying the contour plot.

Extended Capabilities

GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.

Usage notes and limitations:

  • This function accepts GPU arrays, but does not run on a GPU.

For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).

Distributed Arrays
Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.

Usage notes and limitations:

  • This function operates on distributed arrays, but executes in the client MATLAB.

For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).

See Also

Functions

Properties

Introduced before R2006a

You have a modified version of this example. Do you want to open this example with your edits?

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.

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: .

Select web site

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.

Contact your local office

Sours: https://uk.mathworks.com/help/matlab/ref/contourf.html
  1. Hotel by seatac
  2. 805 north traffic
  3. Minecraft black bed
  4. Vintage french labels
  5. Virginia beach radar

fcontour

Main Content

Description

example

plots the contour lines of symbolic expression f(x,y) over the default interval of and y, which is .

example

plots over the interval < < and < < .

example

plots over the interval < < and < < . The function uses to order the variables and assign intervals.

example

uses to set the line style and color. doesn’t support markers.

example

specifies line properties using one or more pair arguments. Use this option with any of the input argument combinations in the previous syntaxes. pair settings apply to all the lines plotted. To set options for individual plots, use the objects returned by .

plots into the axes object instead of the current axes object .

example

returns a function contour object. Use the object to query and modify properties of a specific contour plot. For details, see FunctionContour Properties.

Examples

Plot Contours of Symbolic Expression

Plot the contours of over the default range of and . Show the colorbar. Find a contour's level by matching the contour's color with the colorbar value.

syms xy fcontour(sin(x) + cos(y)) colorbar

Plot Contours of Symbolic Function

Plot the contours of over the default range of and .

syms f(x,y) f(x,y) = sin(x) + cos(y); fcontour(f)

Specify Plotting Interval

Plot over and by specifying the plotting interval as the second argument of .

syms xy f = sin(x) + cos(y); fcontour(f,[-pi/2 pi/2 0 5])

Change Line Style, Color and Width

Plot the contours of as blue, dashed lines by specifying the input. Specify a of . Markers are not supported by .

syms xy fcontour(x^2 - y^2,'--b','LineWidth',2)

Plot Multiple Contour Plots on Same Figure

Plot multiple contour plots either by passing the inputs as a vector or by using to successively plot on the same figure. If you specify and Name-Value arguments, they apply to all contour plots. You cannot specify individual and Name-Value pair arguments for each plot.

Divide a figure into two subplots by using . On the first subplot, plot and by using vector input. On the second subplot, plot the same expressions by using .

syms xy subplot(2,1,1) fcontour([sin(x)+cos(y) x-y]) title('Multiple Contour Plots Using Vector Inputs') subplot(2,1,2) fcontour(sin(x)+cos(y)) hold on fcontour(x-y) title('Multiple Contour Plots Using Hold Command') hold off

Modify Contour Plot After Creation

Plot the contours of . Specify an output to make return the plot object.

syms xy f = exp(-(x/3)^2-(y/3)^2) + exp(-(x+2)^2-(y+2)^2); fc = fcontour(f)
fc = FunctionContour with properties: Function: exp(- x^2/9 - y^2/9) + exp(- (x + 2)^2 - (y + 2)^2) LineColor: 'flat' LineStyle: '-' LineWidth: 0.5000 Fill: off LevelList: [0.2000 0.4000 0.6000 0.8000 1 1.2000 1.4000] Show all properties

Change the to and the to a dashed line by using dot notation to set properties of the object . Visualize contours close to and by setting to .

fc.LineStyle = '--'; fc.LineWidth = 1; fc.LevelList = [1 0.9 0.8 0.2 0.1]; colorbar

Fill Area Between Contours

Fill the area between contours by setting the input of to . If you want interpolated shading instead, use the function with its option set to followed by the command .

Create a plot that looks like a sunset by filling the contours of

syms xy f = erf((y+2)^3) - exp(-0.65*((x-2)^2+(y-2)^2)); fcontour(f,'Fill','on')

Specify Levels for Contour Lines

Set the values at which draws contours by using the option.

syms xy f = sin(x) + cos(y); fcontour(f,'LevelList',[-1 0 1])

Control Resolution of Contour Lines

Control the resolution of contour lines by using the option. Increasing can make smoother, more accurate plots while decreasing it can increase plotting speed.

Divide a figure into two using . In the first subplot, plot the contours of . The corners of the squares do not meet. To fix this issue, increase to in the second subplot. The corners now meet, showing that by increasing you increase the plot's resolution.

syms xy subplot(2,1,1) fcontour(sin(x).*sin(y)) title('Default MeshDensity = 71') subplot(2,1,2) fcontour(sin(x).*sin(y),'MeshDensity',200) title('Increased MeshDensity = 200')

Add Title and Axis Labels and Format Ticks

Plot . Add a title and axis labels. Create the x-axis ticks by spanning the x-axis limits at intervals of . Display these ticks by using the property. Create x-axis labels by using to apply to . Display these labels by using the property. Repeat these steps for the y-axis.

To use LaTeX in plots, see .

syms xy fcontour(x*sin(y)-y*cos(x), [-2*pi 2*pi]) grid on title('xsin(y)-ycos(x) for -2\pi < x < 2\pi and -2\pi < y < 2\pi') xlabel('x') ylabel('y') ax = gca; S = sym(ax.XLim(1):pi/2:ax.XLim(2)); ax.XTick = double(S); ax.XTickLabel = arrayfun(@texlabel, S, 'UniformOutput', false); S = sym(ax.YLim(1):pi/2:ax.YLim(2)); ax.YTick = double(S); ax.YTickLabel = arrayfun(@texlabel, S, 'UniformOutput', false);

Create Animations

Create animations by changing the displayed expression using the property of the function handle, and then using to update the plot. To export to GIF, see .

By varying the variable i from –π/8 to π/8, animate the parametric curve isin(x) + icos(y).

syms xy fc = fcontour(-pi/8.*sin(x)-pi/8.*cos(y)); for i=-pi/8:0.01:pi/8 fc.Function = i.*sin(x)+i.*cos(y); drawnow pause(0.05) end

Input Arguments

collapse all

— Expression or function to be plotted
symbolic expression | symbolic function

Expression or function to be plotted, specified as a symbolic expression or function.

— Plotting range for and
[–5 5] (default) | vector of two numbers

Plotting range for and , specified as a vector of two numbers. The default range is .

— Plotting range for and
[–5 5 –5 5] (default) | vector of four numbers

Plotting range for and , specified as a vector of four numbers. The default range is .

— Axes object
axes object

Axes object. If you do not specify an axes object, then the plot function uses the current axes.

— Line style and color
character vector | string

Line style and color, specified as a character vector or string containing a line style specifier, a color specifier, or both.

Example: specifies red dashed lines

These two tables list the line style and color options.

Line Style SpecifierDescription
Solid line (default)
Dashed line
Dotted line
Dash-dot line
Color SpecifierDescription
yellow
magenta
cyan
red
green
blue
white
black

Name-Value Arguments

Specify optional comma-separated pairs of arguments. is the argument name and is the corresponding value. must appear inside quotes. You can specify several name and value pair arguments in any order as .

Example:

The properties listed here are only a subset. For a complete list, see FunctionContour Properties.

— Number of evaluation points per direction
71 (default) | number

Number of evaluation points per direction, specified as a number. The default is . Because uses adaptive evaluation, the actual number of evaluation points is greater.

Example:

— Fill between contour lines
(default) | on/off logical value

Fill between contour lines, specified as or , or as numeric or logical () or (). A value of is equivalent to true, and is equivalent to . Thus, you can use the value of this property as a logical value. The value is stored as an on/off logical value of type .

  • A value of fill the spaces between contour lines with color.

  • A value of leaves the spaces between the contour lines unfilled.

— Contour levels
vector of z values

Contour levels, specified as a vector of z values. By default, the function chooses values that span the range of values in the property.

Setting this property sets the associated mode property to manual.

Data Types: | | | | | | | | |

— Selection mode for
(default) |

Selection mode for the , specified as one of these values:

  • — Determine the values based on the values.

  • — Use manually specified values. To specify the values, set the property. When the mode is , the values do not change if you change the property or the limits.

— Spacing between contour lines
(default) | scalar numeric value

Spacing between contour lines, specified as a scalar numeric value. For example, specify a value of to draw contour lines at increments of 2. By default, is determined by using the values.

Setting this property sets the associated mode property to .

Example:

Data Types: | | | | | | | | |

— Selection mode for
(default) |

Selection mode for the , specified as one of these values:

  • — Determine the value based on the values.

  • — Use a manually specified value. To specify the value, set the property. When the mode is , the value of does not change when the property or the limits change.

— Color of contour lines
(default) | RGB triplet | hexadecimal color code | | | | ...

Color of contour lines, specified as , an RGB triplet, a hexadecimal color code, a color name, or a short name. To use a different color for each contour line, specify . The color is determined by the contour value of the line, the colormap, and the scaling of data values into the colormap. For more information on color scaling, see .

To use the same color for all the contour lines, specify an RGB triplet, a hexadecimal color code, a color name, or a short name.

For a custom color, specify an RGB triplet or a hexadecimal color code.

  • An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range ; for example, .

  • A hexadecimal color code is a character vector or a string scalar that starts with a hash symbol () followed by three or six hexadecimal digits, which can range from to . The values are not case sensitive. Thus, the color codes , , , and are equivalent.

Alternatively, you can specify some common colors by name. This table lists the named color options, the equivalent RGB triplets, and hexadecimal color codes.

Color NameShort NameRGB TripletHexadecimal Color CodeAppearance
Not applicableNot applicableNot applicableNo color

Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB® uses in many types of plots.

RGB TripletHexadecimal Color CodeAppearance

— Line style
(default) | | | |

Line style, specified as one of the options listed in this table.

Line StyleDescriptionResulting Line
Solid line
Dashed line
Dotted line
Dash-dotted line
No lineNo line

— Line width
(default) | positive value

Line width, specified as a positive value in points, where 1 point = 1/72 of an inch. If the line has markers, then the line width also affects the marker edges.

The line width cannot be thinner than the width of a pixel. If you set the line width to a value that is less than the width of a pixel on your system, the line displays as one pixel wide.

Output Arguments

collapse all

— One or more function contour objects
scalar | vector

One or more function contour objects, returned as a scalar or a vector. These objects are unique identifiers, which you can use to query and modify the properties of a specific contour plot. For details, see FunctionContour Properties.

Algorithms

assigns the symbolic variables in to the axis, then the axis, and determines the order of the variables to be assigned. Therefore, variable and axis names might not correspond. To force to assign x or y to its corresponding axis, create the symbolic function to plot, then pass the symbolic function to .

For example, the following code plots the contour of the surface f(x,y) = sin(y) in two ways. The first way forces the waves to oscillate with respect to the y axis. The second way assigns y to the x axis because it is the first (and only) variable in the symbolic function.

syms xy; f(x,y) = sin(y); figure; subplot(2,1,1) fcontour(f); subplot(2,1,2) fcontour(f(x,y)); % Or fcontour(sin(y));

See Also

Functions

Properties

Introduced in R2016a

You have a modified version of this example. Do you want to open this example with your edits?

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.

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: .

Select web site

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.

Contact your local office

Sours: https://www.mathworks.com/help/symbolic/fcontour.html

Contour Plots in MATLAB®

How to make Contour Plots plots in MATLAB® with Plotly.


Contours of a Function

Create matrices and , that define a grid in the x-y plane. Define matrix as the heights above that grid. Then plot the contours of .

x = linspace(-2*pi,2*pi); y = linspace(0,4*pi); [X,Y] = meshgrid(x,y); Z = sin(X)+cos(Y); contour(X,Y,Z) fig2plotly()

Contours at Twenty Levels

Define as a function of and . In this case, call the function to create , , and . Then plot 20 contours of .

[X,Y,Z] = peaks; contour(X,Y,Z,20) fig2plotly()

Contours at One Level

Display the contours of the function at .

[X,Y,Z] = peaks; v = [1,1]; contour(X,Y,Z,v) fig2plotly()

Dashed Contour Lines

Create a contour plot of the function, and specify the dashed line style.

[X,Y,Z] = peaks; contour(X,Y,Z,'--') fig2plotly()

Contours with Labels

Define as a function of two variables, and . Then create a contour plot of that function, and display the labels by setting the property to .

x = -2:0.2:2; y = -2:0.2:3; [X,Y] = meshgrid(x,y); Z = X.*exp(-X.^2-Y.^2); contour(X,Y,Z,'ShowText','on') fig2plotly()

Custom Line Width

Create a contour plot of the function. Make the contour lines thicker by setting the property to .

Z = peaks; [M,c] = contour(Z); c.LineWidth = 3; fig2plotly()

Contours Over Discontinuous Surface

Insert values wherever there are discontinuities on a surface. The function does not draw contour lines in those regions.

Define matrix as a sampling of the function. Replace all values in column with values. Then plot the contours of the modified matrix.

Z = peaks; Z(:,26) = NaN; contour(Z) fig2plotly()

Contours of Peaks Function

Define as a function of two variables. In this case, call the function to create . Then display a filled contour plot of , letting MATLAB® choose the contour levels.

Z = peaks; contourf(Z) fig2plotly()

Contours at Ten Levels

Define as a function of two variables, and . Then display contours at 10 levels of .

x = linspace(-2*pi,2*pi); y = linspace(0,4*pi); [X,Y] = meshgrid(x,y); Z = sin(X) + cos(Y); contourf(X,Y,Z,10) fig2plotly()

Contours at Specific Levels with Labels

Define as a function of and . In this case, call the function to create , , and . Then display contours at levels and .

The white region corresponds to the heights less than . The purple region corresponds to heights between and . And the yellow region corresponds to heights that are greater than .

[X,Y,Z] = peaks(50); contourf(X,Y,Z,[2 3],'ShowText','on') fig2plotly()

Contours at One Level

Define as a function of and . In this case, call the function to create , , and . Then display contours at .

[X,Y,Z] = peaks; contourf(X,Y,Z,[2 2]) fig2plotly()

Dashed Contour Lines

Create a contour plot, and specify the dashed line style.

[X,Y,Z] = peaks; contourf(X,Y,Z,'--') fig2plotly()

Custom Line Width

Create a filled contour plot. Make the contour lines thicker by setting the property to .

Z = peaks; [M,c] = contourf(Z); c.LineWidth = 3; fig2plotly()

Contours Over Discontinuous Surface

Insert values wherever there are discontinuities on a surface. The function does not draw contour lines in those regions.

Define matrix as a sampling of the function. Replace all values in column with values. Then plot the contours of the modified matrix.

Z = peaks; Z(:,26) = NaN; contourf(Z) fig2plotly()

Contour Plot with Histogram Subplots

t = linspace(-1, 1.2, 2000); x = (t.^3)+(0.3.*randn(1, 2000)); y = (t.^6)+(0.3.*randn(1, 2000)); trace1 = struct(... 'x', x, ... 'y', y, ... 'mode', 'markers', ... 'name', 'points', ... 'marker', struct(... 'color', 'rgb(102,0,0)', ... 'size', 2, ... 'opacity', 0.4), ... 'type', 'scatter'); trace2 = struct(... 'x', x, ... 'y', y, ... 'name', 'density', ... 'ncontours', 20, ... 'colorscale', 'Hot', ... 'reversescale', true, ... 'showscale', false, ... 'type', 'histogram2dcontour'); trace3 = struct(... 'x', x, ... 'name', 'x density', ... 'marker', struct('color', 'rgb(102,0,0)'), ... 'yaxis', 'y2', ... 'type', 'histogram'); trace4 = struct(... 'y', y, ... 'name', 'y density', ... 'marker', struct('color', 'rgb(102,0,0)'), ... 'xaxis', 'x2', ... 'type', 'histogram'); data = {trace1, trace2, trace3, trace4}; layout = struct(... 'showlegend', false, ... 'autosize', false, ... 'width', 600, ... 'height', 550, ... 'xaxis', struct(... 'domain', [0, 0.85], ... 'showgrid', false, ... 'zeroline', false), ... 'yaxis', struct(... 'domain', [0, 0.85], ... 'showgrid', false, ... 'zeroline', false), ... 'margin', struct('t', 50), ... 'hovermode', 'closest', ... 'bargap', 0, ... 'xaxis2', struct(... 'domain', [0.85, 1], ... 'showgrid', false, ... 'zeroline', false), ... 'yaxis2', struct(... 'domain', [0.85, 1], ... 'showgrid', false, ... 'zeroline', false)); plotly(data, struct('layout', layout));
Sours: https://plotly.com/matlab/contour-plots/

Plot matlab contour

MATLAB Function Reference   
contour

Two-dimensional contour plot

Syntax

  • contour(Z) contour(Z,n) contour(Z,v) contour(X,Y,Z) contour(X,Y,Z,n) contour(X,Y,Z,v) contour(...,) [C,h] = contour(...)

Description

A contour plot displays isolines of matrix . Label the contour lines using .

draws a contour plot of matrix , where is interpreted as heights with respect to the x-y plane. must be at least a 2-by-2 matrix. The number of contour levels and the values of the contour levels are chosen automatically based on the minimum and maximum values of . The ranges of the x- and y-axis are and , where .

draws a contour plot of matrix with contour levels.

draws a contour plot of matrix with contour lines at the data values specified in vector . The number of contour levels is equal to . To draw a single contour of level , use .

draw contour plots of . and specify the x- and y-axis limits. When and are matrices, they must be the same size as , in which case they specify a surface as does.

draws the contours using the line type and color specified by . contour ignores marker symbols.

returns the contour matrix (see ) and a vector of handles to graphics objects. uses the contour matrix to create the labels. creates patch graphics objects unless you specify , in which case creates line graphics objects.

Remarks

If you do not specify , and control the color.

If or is irregularly spaced, calculates contours using a regularly spaced contour grid, then transforms the data to or .

Examples

To view a contour plot of the function

over the range -2 x 2, -2 y 3, create matrix using the statements

  • [X,Y] = meshgrid(-2:.2:2,-2:.2:3); Z = X.*exp(-X.^2-Y.^2);

Then, generate a contour plot of .

  • [C,h] = contour(X,Y,Z); clabel(C,h) colormap cool

View the same function over the same range with 20 evenly spaced contour lines and colored with the default colormap .

  • contour(X,Y,Z,20)

Use to create smoother contours. Also set the contour label text to a light yellow and the to light gray.

  • Z = magic(4); [C,h] = contour(interp2(Z,4)); h = clabel(C,h); set(h,'BackgroundColor',[1 1 .6],... 'Edgecolor',[.7 .7 .7])

See Also

, , , , ,

Contour Plots category for related functions

Contour Plots section for more examples


  continue contour3 

Sours: http://www.ece.northwestern.edu/local-apps/matlabhelp/techdoc/ref/contour.html
Contour plots - Multivariable calculus - Khan Academy

contour

Main Content

  • Contour plot

Description

example

creates a contour plot containing the isolines of matrix , where contains height values on the x-y plane. MATLAB® automatically selects the contour lines to display. The column and row indices of are the x and y coordinates in the plane, respectively.

example

specifies the x and y coordinates for the values in .

example

specifies the contour lines to display as the last argument in any of the previous syntaxes. Specify as a scalar value to display the contour lines at automatically chosen levels (heights). To draw the contour lines at specific heights, specify as a vector of monotonically increasing values. To draw the contours at one height (), specify as a two-element row vector .

example

specifies the style and color of the contour lines.

example

specifies additional options for the contour plot using one or more name-value pair arguments. Specify the options after all other input arguments. For a list of properties, see Contour Properties.

displays the contour plot in the target axes. Specify the axes as the first argument in any of the previous syntaxes.

returns the contour matrix , which contains the (x, y) coordinates of the vertices at each level.

example

returns the contour matrix and the contour object . Use to set properties after displaying the contour plot.

Examples

collapse all

Contours of a Function

Create matrices and , that define a grid in the x-y plane. Define matrix as the heights above that grid. Then plot the contours of .

x = linspace(-2*pi,2*pi); y = linspace(0,4*pi); [X,Y] = meshgrid(x,y); Z = sin(X)+cos(Y); contour(X,Y,Z)

Contours at Twenty Levels

Define as a function of and . In this case, call the function to create , , and . Then plot 20 contours of .

[X,Y,Z] = peaks; contour(X,Y,Z,20)

Contours at One Level

Display the contours of the function at .

[X,Y,Z] = peaks; v = [1,1]; contour(X,Y,Z,v)

Dashed Contour Lines

Create a contour plot of the function, and specify the dashed line style.

[X,Y,Z] = peaks; contour(X,Y,Z,'--')

Contours with Labels

Define as a function of two variables, and . Then create a contour plot of that function, and display the labels by setting the property to .

x = -2:0.2:2; y = -2:0.2:3; [X,Y] = meshgrid(x,y); Z = X.*exp(-X.^2-Y.^2); contour(X,Y,Z,'ShowText','on')

Custom Line Width

Create a contour plot of the function. Make the contour lines thicker by setting the property to .

Z = peaks; [M,c] = contour(Z); c.LineWidth = 3;

Contours Over Discontinuous Surface

Insert values wherever there are discontinuities on a surface. The function does not draw contour lines in those regions.

Define matrix as a sampling of the function. Replace all values in column with values. Then plot the contours of the modified matrix.

Z = peaks; Z(:,26) = NaN; contour(Z)

Input Arguments

collapse all

x-coordinates
matrix | vector

x-coordinates, specified as a matrix the same size as , or as a vector with length , where . The default value of is the vector .

When is a matrix, the values must be strictly increasing or decreasing along one dimension and remain constant along the other dimension. The dimension that varies must be the opposite of the dimension that varies in . You can use the function to create and matrices.

When is a vector, the values must be strictly increasing or decreasing.

Example:

Example:

Example:

The property of the object stores the x-coordinates.

Data Types: | | | | | | | | |

y-coordinates
matrix | vector

y-coordinates, specified as a matrix the same size as , or as a vector with length , where . The default value of is the vector .

When is a matrix, the values must be strictly increasing or decreasing along one dimension and remain constant along the other dimension. The dimension that varies must be the opposite of the dimension that varies in . You can use the function to create the and matrices.

When is a vector, the values must be strictly increasing or decreasing.

Example:

Example:

Example:

The property of the object stores the y-coordinates.

Data Types: | | | | | | | | |

z-coordinates
matrix

z-coordinates, specified as a matrix. This matrix must have at least two rows and two columns, and it must contain at least two different values.

Example:

The property of the object stores the z-coordinates.

Data Types: | | | | | | | | |

— Levels
scalar | vector

Contour levels, specified as a scalar whole number or a vector. Use this argument to control the number and location of the contour lines. When you do not specify the levels, the function chooses the levels automatically.

  • To draw contour lines at n automatically chosen heights, specify levels as the scalar value n.

  • To draw the contour lines at specific heights, specify as a vector of monotonically increasing values.

  • To draw contour lines at a single height , specify as a two-element row vector .

Example: draws contour lines at 10 automatically chosen heights on the function.

Example: draws contour lines at 3 specific heights on the function: , , and .

Example: draws contour lines to show where the height of the function is .

Data Types: | | | | | | | | |

— Line style and color
character vector | string scalar

Line style and color, specified as a character vector or string scalar containing characters and symbols. The characters and symbols can appear in any order. You can specify the line style, line color, or both. Marker symbols such as are ignored.

Example: is a green dashed line.

Line StyleDescriptionResulting Line
Solid line
Dashed line
Dotted line
Dash-dotted line
Color NameShort NameAppearance

— Target axes
object

Target axes, specified as an object. If you do not specify the axes, then plots into the current axes.

Name-Value Arguments

Specify optional comma-separated pairs of arguments. is the argument name and is the corresponding value. must appear inside quotes. You can specify several name and value pair arguments in any order as .

Example: displays the contour line labels.

Note

The properties listed here are only a subset. For a complete list, see Contour Properties.

— Contour line labels
(default) | on/off logical value

Contour line labels, specified as or , or as numeric or logical () or (). A value of is equivalent to , and is equivalent to . Thus, you can use the value of this property as a logical value. The value is stored as an on/off logical value of type .

  • — Display the height values along the contour lines.

  • — Do not label the contour lines.

— Line Width
(default) | positive value

Contour line width, specified as a positive value in points. One point equals 1/72 inch.

— Label spacing
(default) | scalar

Label spacing along the contour lines, specified as a scalar value in points, where one point is 1/72 inch. Use this property to control the number of contour labels along the contour lines. Smaller values produce more labels.

You must set the property to for the property to have an effect.

If you use the function to display the labels, then the property has no effect and the plot displays one label per line.

Output Arguments

collapse all

— Contour matrix
matrix

Contour matrix, returned as two-row matrix. This matrix contains the contour levels (heights) and the coordinates of the vertices at each level. The data is arranged sequentially in n sets of columns for n contour lines:

  • The first column in each set contains the contour level and the number of vertices at that level. The top number is the contour level, and the bottom number is the number of vertices.

  • Subsequent columns in the set are the (x, y) coordinates of the vertices. Each column represents an ordered pair. The top number is the x-coordinate, and the bottom number is the y-coordinate.

For example, here are the first few columns of the contour matrix :

The property of the object stores the contour matrix.

— Contour object
object

object. Use this object to set properties after displaying the contour plot.

Extended Capabilities

GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.

Usage notes and limitations:

  • This function accepts GPU arrays, but does not run on a GPU.

For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).

Distributed Arrays
Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.

Usage notes and limitations:

  • This function operates on distributed arrays, but executes in the client MATLAB.

For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).

See Also

Functions

Properties

Introduced before R2006a

You have a modified version of this example. Do you want to open this example with your edits?

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.

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: .

Select web site

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.

Contact your local office

Sours: https://in.mathworks.com/help/matlab/ref/contour.html

You will also like:

contour

Main Content

  • Contour plot

Description

example

creates a contour plot containing the isolines of matrix , where contains height values on the x-y plane. MATLAB® automatically selects the contour lines to display. The column and row indices of are the x and y coordinates in the plane, respectively.

example

specifies the x and y coordinates for the values in .

example

specifies the contour lines to display as the last argument in any of the previous syntaxes. Specify as a scalar value to display the contour lines at automatically chosen levels (heights). To draw the contour lines at specific heights, specify as a vector of monotonically increasing values. To draw the contours at one height (), specify as a two-element row vector .

example

specifies the style and color of the contour lines.

example

specifies additional options for the contour plot using one or more name-value pair arguments. Specify the options after all other input arguments. For a list of properties, see Contour Properties.

displays the contour plot in the target axes. Specify the axes as the first argument in any of the previous syntaxes.

returns the contour matrix , which contains the (x, y) coordinates of the vertices at each level.

example

returns the contour matrix and the contour object . Use to set properties after displaying the contour plot.

Examples

collapse all

Contours of a Function

Create matrices and , that define a grid in the x-y plane. Define matrix as the heights above that grid. Then plot the contours of .

x = linspace(-2*pi,2*pi); y = linspace(0,4*pi); [X,Y] = meshgrid(x,y); Z = sin(X)+cos(Y); contour(X,Y,Z)

Contours at Twenty Levels

Define as a function of and . In this case, call the function to create , , and . Then plot 20 contours of .

[X,Y,Z] = peaks; contour(X,Y,Z,20)

Contours at One Level

Display the contours of the function at .

[X,Y,Z] = peaks; v = [1,1]; contour(X,Y,Z,v)

Dashed Contour Lines

Create a contour plot of the function, and specify the dashed line style.

[X,Y,Z] = peaks; contour(X,Y,Z,'--')

Contours with Labels

Define as a function of two variables, and . Then create a contour plot of that function, and display the labels by setting the property to .

x = -2:0.2:2; y = -2:0.2:3; [X,Y] = meshgrid(x,y); Z = X.*exp(-X.^2-Y.^2); contour(X,Y,Z,'ShowText','on')

Custom Line Width

Create a contour plot of the function. Make the contour lines thicker by setting the property to .

Z = peaks; [M,c] = contour(Z); c.LineWidth = 3;

Contours Over Discontinuous Surface

Insert values wherever there are discontinuities on a surface. The function does not draw contour lines in those regions.

Define matrix as a sampling of the function. Replace all values in column with values. Then plot the contours of the modified matrix.

Z = peaks; Z(:,26) = NaN; contour(Z)

Input Arguments

collapse all

x-coordinates
matrix | vector

x-coordinates, specified as a matrix the same size as , or as a vector with length , where . The default value of is the vector .

When is a matrix, the values must be strictly increasing or decreasing along one dimension and remain constant along the other dimension. The dimension that varies must be the opposite of the dimension that varies in . You can use the function to create and matrices.

When is a vector, the values must be strictly increasing or decreasing.

Example:

Example:

Example:

The property of the object stores the x-coordinates.

Data Types: | | | | | | | | |

y-coordinates
matrix | vector

y-coordinates, specified as a matrix the same size as , or as a vector with length , where . The default value of is the vector .

When is a matrix, the values must be strictly increasing or decreasing along one dimension and remain constant along the other dimension. The dimension that varies must be the opposite of the dimension that varies in . You can use the function to create the and matrices.

When is a vector, the values must be strictly increasing or decreasing.

Example:

Example:

Example:

The property of the object stores the y-coordinates.

Data Types: | | | | | | | | |

z-coordinates
matrix

z-coordinates, specified as a matrix. This matrix must have at least two rows and two columns, and it must contain at least two different values.

Example:

The property of the object stores the z-coordinates.

Data Types: | | | | | | | | |

— Levels
scalar | vector

Contour levels, specified as a scalar whole number or a vector. Use this argument to control the number and location of the contour lines. When you do not specify the levels, the function chooses the levels automatically.

  • To draw contour lines at n automatically chosen heights, specify levels as the scalar value n.

  • To draw the contour lines at specific heights, specify as a vector of monotonically increasing values.

  • To draw contour lines at a single height , specify as a two-element row vector .

Example: draws contour lines at 10 automatically chosen heights on the function.

Example: draws contour lines at 3 specific heights on the function: , , and .

Example: draws contour lines to show where the height of the function is .

Data Types: | | | | | | | | |

— Line style and color
character vector | string scalar

Line style and color, specified as a character vector or string scalar containing characters and symbols. The characters and symbols can appear in any order. You can specify the line style, line color, or both. Marker symbols such as are ignored.

Example: is a green dashed line.

Line StyleDescriptionResulting Line
Solid line
Dashed line
Dotted line
Dash-dotted line
Color NameShort NameAppearance

— Target axes
object

Target axes, specified as an object. If you do not specify the axes, then plots into the current axes.

Name-Value Arguments

Specify optional comma-separated pairs of arguments. is the argument name and is the corresponding value. must appear inside quotes. You can specify several name and value pair arguments in any order as .

Example: displays the contour line labels.

Note

The properties listed here are only a subset. For a complete list, see Contour Properties.

— Contour line labels
(default) | on/off logical value

Contour line labels, specified as or , or as numeric or logical () or (). A value of is equivalent to , and is equivalent to . Thus, you can use the value of this property as a logical value. The value is stored as an on/off logical value of type .

  • — Display the height values along the contour lines.

  • — Do not label the contour lines.

— Line Width
(default) | positive value

Contour line width, specified as a positive value in points. One point equals 1/72 inch.

— Label spacing
(default) | scalar

Label spacing along the contour lines, specified as a scalar value in points, where one point is 1/72 inch. Use this property to control the number of contour labels along the contour lines. Smaller values produce more labels.

You must set the property to for the property to have an effect.

If you use the function to display the labels, then the property has no effect and the plot displays one label per line.

Output Arguments

collapse all

— Contour matrix
matrix

Contour matrix, returned as two-row matrix. This matrix contains the contour levels (heights) and the coordinates of the vertices at each level. The data is arranged sequentially in n sets of columns for n contour lines:

  • The first column in each set contains the contour level and the number of vertices at that level. The top number is the contour level, and the bottom number is the number of vertices.

  • Subsequent columns in the set are the (x, y) coordinates of the vertices. Each column represents an ordered pair. The top number is the x-coordinate, and the bottom number is the y-coordinate.

For example, here are the first few columns of the contour matrix :

The property of the object stores the contour matrix.

— Contour object
object

object. Use this object to set properties after displaying the contour plot.

Extended Capabilities

GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.

Usage notes and limitations:

  • This function accepts GPU arrays, but does not run on a GPU.

For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).

Distributed Arrays
Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.

Usage notes and limitations:

  • This function operates on distributed arrays, but executes in the client MATLAB.

For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).

See Also

Functions

Properties

Introduced before R2006a

Sie haben eine geänderte Version dieses Beispiels. Möchten Sie dieses Beispiel mit Ihren Änderungen öffnen?

Sie haben auf einen Link geklickt, der diesem MATLAB-Befehl entspricht:

Führen Sie den Befehl durch Eingabe in das MATLAB-Befehlsfenster aus. Webbrowser unterstützen keine MATLAB-Befehle.

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: .

Select web site

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.

Contact your local office

Sours: https://de.mathworks.com/help/matlab/ref/contour.html


11553 11554 11555 11556 11557