loglog(X,Y) plots x- và y-coordinates using a base-10 logarithmic scale on the x-axis & the y-axis.
Bạn đang xem: Log plot for power relationships
To plot a set of coordinates connected by line segments, specify X and Y as vectors of the same length.
To plot multiple sets of coordinates on the same set of axes, specify at least one of X or Y as a matrix.
loglog(X1,Y1,...,Xn,Yn) plots multiple pairs of x- and y-coordinates on the same set of axes. Use this syntax as an alternative khổng lồ specifying coordinates as matrices.
loglog(X1,Y1,LineSpec1,...,Xn,Yn,LineSpecn) assigns specific line styles, markers, và colors khổng lồ each x-y pair. You can specify LineSpec for some x-y pairs and omit it for others. For example, loglog(X1,Y1,"o",X2,Y2) specifies markers for the first x-y pair but not for the second pair.
If Y is a vector, the x-coordinates range from 1 to lớn length(Y).
If Y is a matrix, the plot contains one line for each column in Y. The x-coordinates range from 1 lớn the number of rows in Y.
If Y contains complex numbers, loglog plots the imaginary part of Y versus the real part of Y. However, if you specify both X & Y, MATLAB® ignores the imaginary part.
loglog(Y,LineSpec) plots Y using implicit x-coordinates, & specifies the line style, marker, and color.
loglog(tbl,xvar,yvar) plots the variables xvar and yvar from the table tbl. Lớn plot one data set, specify one variable for xvar & one variable for yvar. Lớn plot multiple data sets, specify multiple variables for xvar, yvar, or both. If both arguments specify multiple variables, they must specify the same number of variables. (since R2022a)
loglog(tbl,yvar) plots the specified variable from the table against the row indices of the table. Timetables are not supported for this syntax. (since R2022a)
loglog(ax,___) displays the plot in the target axes. Specify the axes as the first argument in any of the previous syntaxes.
loglog(___,Name,Value) specifies Line properties using one or more name-value arguments. The properties apply lớn all the plotted lines. Specify the name-value arguments after all the arguments in any of the previous syntaxes. For a menu of properties, see Line Properties.
p = loglog(___) returns a Line object or an array of Line objects. Use p. To modify properties of the plot after creating it. For a danh mục of properties, see Line Properties.
Define x as a vector of 50 logarithmically spaced numbers on the interval <10-1,102>. Define y as 2x. Then plot x và y, & call the grid function to show the grid lines.
Create a vector of x-coordinates và two vectors of y-coordinates. Plot two lines by passing comma-separated x-y pairs lớn loglog.
Alternatively, you can create the same plot with one x-y pair by specifying y as a matrix: loglog(x,).
Call the yticks function khổng lồ position the y-axis tick values at whole number increments along the y-axis. Then create x- and y-axis labels by calling the xlabel và ylabel functions.
Create a phối of x- and y-coordinates and display them in a log-log plot. Specify the line style as "s" to lớn display square markers without connecting lines. Specify the marker fill màu sắc as the RGB triplet <0 0.447 0.741>, which corresponds khổng lồ a dark shade of blue.
Create two sets of x- & y-coordinates & display them in a log-log plot. Display a legend in the upper left corner of the plot by calling the legend function and specifying the location as "northwest".
x = logspace(-1,2,10000);y1 = 5 + 3*sin(x/4);y2 = 5 - 3*sin(x/4);loglog(x,y1,x,y2,"--")legend("Signal 1","Signal 2","Location","northwest")
When you specify only one coordinate vector, loglog plots those coordinates against the values 1:length(y). For example, define y as a vector of 6 values between 0.001 & 100. Create a log-log plot of y.
If you specify y as a matrix, the columns of y are plotted against the values 1:size(y,1). For example, define y as a 5-by-3 matrix và pass it to lớn the loglog function. The resulting plot contains 3 lines, each of which has x-coordinates that range from 1 to 5.
y = <0.0010 0.0100 0.1000 0.0100 0.1000 1.0000 0.1000 1.0000 10.0000 1.0000 10.5000 100.0000 10.0000 100.0000 1000.0000>;loglog(y)grid on
Since R2022a
A convenient way lớn plot data from a table is to lớn pass the table khổng lồ the loglog function và specify the variables khổng lồ plot.
Create a table containing two variables. Then display the first three rows of the table.
Plot the đầu vào variable on the
x-axis & the output đầu ra variable on the
y-axis. Return the Line object as p, and turn the axes grid on. Notice that the axis labels match the variable names.
To modify aspects of the line, mix the LineStyle, Color, and Marker properties on the Line object. For example, change the line to lớn a red dotted line with point markers.
Since R2022a
Create a table containing three variables. Then display the first three rows in the table.
Input = logspace(-1,2)";Output1 = 10.^Input;Output2 = 1./10.^Input;tbl = table(Input,Output1,Output2);head(tbl,3)
Plot the input variable on the x-axis and the Output1 & Output2 variables on the y-axis. Showroom a legend. Notice that the legend labels match the variable names.
Create a tiled chart layout in the "flow" tile arrangement, so that the axes fill the available space in the layout. Next, hotline the nexttile function lớn create an axes object and return it as ax1. Then display a log-log plot by passing ax1 to the loglog function.
x-coordinates, specified as a scalar, vector, or matrix. The form size and shape of X depends on the shape of your data & the type of plot you want lớn create. This table describes the most common situations.
Type of PlotHow to Specify Coordinates
Single point | Specify X và Y as scalars & include a marker. For example:
|
One set of points | Specify X và Y as any combination of row or column vectors of the same length. For example:
|
Multiple sets of points(using matrices) | If all the sets chia sẻ the same x- or y-coordinates, specify the shared coordinates as a vector and the other coordinates as a matrix. The length of the vector must match one of the dimensions of the matrix. For example: If the matrix is square, loglog plots one line for each column in the matrix. Alternatively, specify X và Y as matrices of equal size. In this case, loglog plots each column of Y against the corresponding column of X. For example:
If the coordinates include positive và negative values, only the positive values are displayed. If the coordinates are all negative, all of the values are displayed on a log scale with the appropriate sign. Zero values are not displayed. y-coordinates, specified as a scalar, vector, or matrix. The size and shape of Y depends on the shape of your data và the type of plot you want lớn create. This table describes the most common situations.
Type of PlotHow to Specify Coordinates Single point | Specify X và Y as scalars & include a marker. For example:
| One phối of points | Specify X and Y as any combination of row or column vectors of the same length. For example:
| Multiple sets of points(using matrices) | If all the sets giới thiệu the same x- or y-coordinates, specify the shared coordinates as a vector and the other coordinates as a matrix. The length of the vector must match one of the dimensions of the matrix. For example: If the matrix is square, loglog plots one line for each column in the matrix. Alternatively, specify X & Y as matrices of equal size. In this case, loglog plots each column of Y against the corresponding column of X. For example:
If the coordinates include positive and negative values, only the positive values are displayed. If the coordinates are all negative, all of the values are displayed on a log scale with the appropriate sign. Zero values are not displayed.
Line style, marker, và color, specified as a character vector or string containing symbols. The symbols can appear in any order. You vì not need khổng lồ specify all three characteristics (line style, marker, & color). For example, if you omit the line style and specify the marker, then the plot shows only the marker and no line. Example: "--or" is a red dashed line with circle markers
xvar — Table variables containing x-coordinatescharacter vector | string array | cell array | pattern | numeric scalar or vector | logical vector | vartype() Table variables containing the x-coordinates, specified using one of the indexing schemes from the table.
"A" or "A" — A variable called A <"A","B"> or "A","B" — Two variables called A và B "Var"+digitsPattern(1) — Variables named "Var" followed by a single digit
An index number that refers lớn the location of a variable in the table. A vector of numbers. A logical vector. Typically, this vector is the same length as the number of variables, but you can omit trailing 0 or false values.
3 — The third variable from the table <2 3> — The second và third variables from the table — The third variable The table variables you specify can contain any numeric values. However, loglog might exclude negative và zero values from the plot in the same way as it does when you specify X and Y as vectors containing negative or zero values. If xvar & yvar both specify multiple variables, the number of variables must be the same. Example: loglog(tbl,<"x1","x2">,"y") specifies the table variables named x1 and x2 for the x-coordinates. Example: loglog(tbl,2,"y") specifies the second variable for the x-coordinates. Example: loglog(tbl,vartype("numeric"),"y") specifies all numeric variables for the x-coordinates.
yvar — Table variables containing y-coordinates character vector | string array | cell array | pattern | numeric scalar or vector | logical vector | vartype() Table variables containing the y-coordinates, specified using one of the indexing schemes from the table.
Indexing SchemeExamples Variable names:
A string, character vector, or cell array.
"A" or "A" — A variable called A <"A","B"> or "A","B" — Two variables called A và B "Var"+digitsPattern(1) — Variables named "Var" followed by a single digit
| Variable index:
An index number that refers to lớn the location of a variable in the table. A vector of numbers. A logical vector. Typically, this vector is the same length as the number of variables, but you can omit trailing 0 or false values.
3 — The third variable from the table <2 3> — The second và third variables from the table — The third variable
| Variable type:
vartype("categorical") — All the variables containing categorical values The table variables you specify can contain any numeric values. However, loglog might exclude negative và zero values from the plot in the same way as it does when you specify X và Y as vectors containing negative or zero values. If xvar and yvar both specify multiple variables, the number of variables must be the same. Example: loglog(tbl,"x",<"y1","y2">) specifies the table variables named y1 và y2 for the y-coordinates. Example: loglog(tbl,"x",2) specifies the second variable for the y-coordinates. Example: loglog(tbl,"x",vartype("numeric")) specifies all numeric variables for the y-coordinates.
ax — Target axes Axes object Target axes, specified as an Axes object. If you bởi vì not specify the axes and if the current axes is Cartesian, then loglog uses the current axes.
Name-Value Arguments
Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name và Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter. Before R2021a, use commas khổng lồ separate each name & value, và enclose Name in quotes. Example: loglog(<1 2>,<3 4>,"Color","red") specifies a red line for the plot.
Note The properties listed here are only a subset. For a complete list, see Line Properties.
Color — màu sắc <0 0.4470 0.7410> (default) | RGB triplet | hexadecimal màu sắc code | "r" | "g" | "b" | ... Color, specified as an RGB triplet, a hexadecimal màu sắc code, a color name, or a short name. The color you specify sets the line color. It also sets the marker edge color when the MarkerEdgeColor property is set to lớn "auto". For a custom color, specify an RGB triplet or a hexadecimal màu sắc code.
An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, & blue components of the color. The intensities must be in the range <0,1>; for example, <0.4 0.6 0.7>. 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 0 to lớn F. The values are not case sensitive. Thus, the màu sắc codes "#FF8800", "#ff8800", "#F80", và "#f80" are equivalent.
Alternatively, you can specify some common colors by name. This table lists the named màu sắc options, the equivalent RGB triplets, and hexadecimal màu sắc codes.
Color NameShort NameRGB TripletHexadecimal màu sắc CodeAppearance "red" | "r" | <1 0 0> | "#FF0000" |
| "green" | "g" | <0 1 0> | "#00FF00" |
| "blue" | "b" | <0 0 1> | "#0000FF" |
| "cyan" | "c" | <0 1 1> | "#00FFFF" |
| "magenta" | "m" | <1 0 1> | "#FF00FF" |
| "yellow" | "y" | <1 1 0> | "#FFFF00" |
| "black" | "k" | <0 0 0> | "#000000" |
| "white" | "w" | <1 1 1> | "#FFFFFF" |
| "none" | Not applicable | Not applicable | Not applicable | No color |
Here are the RGB triplets và hexadecimal màu sắc codes for the default colors MATLAB uses in many types of plots.
RGB TripletHexadecimal màu sắc CodeAppearance <0 0.4470 0.7410> | "#0072BD" |
| <0.8500 0.3250 0.0980> | "#D95319" |
| <0.9290 0.6940 0.1250> | "#EDB120" |
| <0.4940 0.1840 0.5560> | "#7E2F8E" |
| <0.4660 0.6740 0.1880> | "#77AC30" |
| <0.3010 0.7450 0.9330> | "#4DBEEE" |
LineWidth — Line width 0.5 (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 lớn a value that is less than the width of a px on your system, the line displays as one px wide.
MarkerSize — Marker size 6 (default) | positive value
Marker size, specified as a positive value in points, where 1 point = 1/72 of an inch.
MarkerEdgeColor — Marker outline color "auto" (default) | RGB triplet | hexadecimal màu sắc code | "r" | "g" | "b" | ... Marker outline color, specified as "auto", an RGB triplet, a hexadecimal color code, a màu sắc name, or a short name. The mặc định value of "auto" uses the same color as the màu sắc property. 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, & blue components of the color. The intensities must be in the range <0,1>; for example, <0.4 0.6 0.7>. 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 0 to lớn F. The values are not case sensitive. Thus, the màu sắc codes "#FF8800", "#ff8800", "#F80", và "#f80" are equivalent.
Alternatively, you can specify some common colors by name. This table lists the named màu sắc options, the equivalent RGB triplets, và hexadecimal màu sắc codes.
Color NameShort NameRGB TripletHexadecimal color CodeAppearance "red" | "r" | <1 0 0> | "#FF0000" |
| "green" | "g" | <0 1 0> | "#00FF00" |
| "blue" | "b" | <0 0 1> | "#0000FF" |
| "cyan" | "c" | <0 1 1> | "#00FFFF" |
| "magenta" | "m" | <1 0 1> | "#FF00FF" |
| "yellow" | "y" | <1 1 0> | "#FFFF00" |
| "black" | "k" | <0 0 0> | "#000000" |
| "white" | "w" | <1 1 1> | "#FFFFFF" |
| "none" | Not applicable | Not applicable | Not applicable | No color |
Here are the RGB triplets & hexadecimal màu sắc codes for the mặc định colors MATLAB uses in many types of plots.
RGB TripletHexadecimal màu sắc CodeAppearance <0 0.4470 0.7410> | "#0072BD" |
| <0.8500 0.3250 0.0980> | "#D95319" |
| <0.9290 0.6940 0.1250> | "#EDB120" |
| <0.4940 0.1840 0.5560> | "#7E2F8E" |
| <0.4660 0.6740 0.1880> | "#77AC30" |
| <0.3010 0.7450 0.9330> | "#4DBEEE" |
MarkerFaceColor — Marker fill màu sắc "none" (default) | "auto" | RGB triplet | hexadecimal màu sắc code | "r" | "g" | "b" | ... Marker fill color, specified as "auto", an RGB triplet, a hexadecimal màu sắc code, a màu sắc name, or a short name. The "auto" option uses the same color as the màu sắc property of the parent axes. If you specify "auto" và the axes plot box is invisible, the marker fill màu sắc is the color of the figure. For a custom color, specify an RGB triplet or a hexadecimal màu sắc code.
An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, và blue components of the color. The intensities must be in the range <0,1>; for example, <0.4 0.6 0.7>. 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 0 to lớn F. The values are not case sensitive. Thus, the màu sắc codes "#FF8800", "#ff8800", "#F80", and "#f80" are equivalent.
Alternatively, you can specify some common colors by name. This table lists the named màu sắc options, the equivalent RGB triplets, & hexadecimal màu sắc codes.
Color NameShort NameRGB TripletHexadecimal màu sắc CodeAppearance "red" | "r" | <1 0 0> | "#FF0000" |
| "green" | "g" | <0 1 0> | "#00FF00" |
| "blue" | "b" | <0 0 1> | "#0000FF" |
| "cyan" | "c" | <0 1 1> | "#00FFFF" |
| "magenta" | "m" | <1 0 1> | "#FF00FF" |
| "yellow" | "y" | <1 1 0> | "#FFFF00" |
| "black" | "k" | <0 0 0> | "#000000" |
| "white" | "w" | <1 1 1> | "#FFFFFF" |
| "none" | Not applicable | Not applicable | Not applicable | No color |
Here are the RGB triplets & hexadecimal color codes for the default colors MATLAB uses in many types of plots.
RGB TripletHexadecimal màu sắc CodeAppearance <0 0.4470 0.7410> | "#0072BD" |
| <0.8500 0.3250 0.0980> | "#D95319" |
| <0.9290 0.6940 0.1250> | "#EDB120" |
| <0.4940 0.1840 0.5560> | "#7E2F8E" |
| <0.4660 0.6740 0.1880> | "#77AC30" |
| <0.3010 0.7450 0.9330> | "#4DBEEE" |
Tips
Use NaN or Inf lớn create breaks in the lines. For example, this code plots a line with a break between y=2 and y=4. loglog(<1 2 3 4 5>,<1 2 NaN 4 5>)
AlgorithmsThe loglog function plots coordinates on a log scale by setting the XScale & YScale properties of the axes khổng lồ "log". However, if the axes hold state is "on" before you call loglog, those properties bởi vì not change, and the plot might display on a linear or semilog scale.
Extended Capabilities
GPU Arrays Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
Usage notes và 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 ArraysPartition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.
Usage notes và 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).
Version HistoryIntroduced before R2006a
expand all
R2022a: Pass tables directly to loglog
Create plots by passing a table to the loglog function followed by the variables you want to plot. When you specify your data as a table, the axis labels & the legend (if present) are automatically labeled using the table variable names.
See AlsoFunctionsProperties
Topics × Open Example You have a modified version of this example. Vì you want to open this example with your edits? No, overwrite the modified version Yes × MATLAB Command You clicked a link that corresponds lớn this MATLAB command: Run the command by entering it in the MATLAB Command Window. Website browsers vì not tư vấn MATLAB commands. Close × Select a web Site Choose a web site to get translated nội dung where available & see local events & offers. Based on your location, we recommend that you select: . You can also select a web site from the following list: How to Get Best Site PerformanceSelect the đài loan trung quốc site (in Chinese or English) for best site performance. Other magdalenarybarikova.com country sites are not optimized for visits from your location.
Xem thêm: Công Ty Tài Chính Vpbank Fc Tra Cứu Khoản Vay Vpbank Nhanh Nhất 2022
Americas Europe Switzerland Asia Pacific 中国 Contact your local office
magdalenarybarikova.com Accelerating the pace of engineering & science magdalenarybarikova.com is the leading developer of mathematical computing software for engineers & scientists.
Lịch thi đấu World Cup
|
|
|
|
|
|