fill3 matlab. fill3() does not fill between planes. fill3 matlab

 
fill3() does not fill between planesfill3 matlab  Skip to content

fill3(X,Y,Z,C) fills three-dimensional. 영역 하나를 플로팅하려면 X, Y, Z 를 벡터로 지정하십시오. However, when I plot the white polygon with FaceALpha=1 above transparent elements, I can still see those elements below the polygon. I'm trying to plot a signal, for example cos(x), with a red gradient colormap for positive values and a blue one for negative values. It is possible to do this, but it involves some details which aren't obvious, so let's walk through what's involved. First, specify the transparency values by setting the AlphaData property to an array the same size as the ZData property. C determines the patch colors. Description. [x,y] = meshgrid (1:15,1:15); z = peaks (15); T = delaunay. shp represents a polyhedron. 7676 10 0. Show 3 older comments. 0. Copy. CDataMapping = 'scaled'; MATLAB Graphics 2-D and 3-D Plots Surfaces, Volumes, and Polygons Surface and Mesh Plots Find more on Surface and Mesh Plots in Help Center and File Exchange Tags Call the tiledlayout function to create a 2-by-1 tiled chart layout. . polar accepts only one pair of theta and rho inputs. The shading function controls the color shading of surface and patch graphics objects. shading flat each mesh line segment and face has a constant color determined by the color value at the endpoint of the segment or the corner of the face that has the smallest index or indices. Accepted Answer. e. Create Polar Scatter Plot. The fill function creates colored polygons. The third vector is the middle top corner. with the following properties: * EDGES : 3-elements vector that defines the length of cube edges. Create matrices x and y. please take a look to my code. X, Y, and Z triplets specify the polygon vertices. If you are you used to 255 color values from HTML for example, you can divide by 255 to get a value between 0 and 1. patches (end) ;blackLine. fill3 Si es necesario, conecta el último vértice al primer vértice para cerrar estos polígonos. h1=fill3 (X,Y,Z,C) 4x1 Patch array: Patch. viscircles ( ___,Name,Value) utiliza argumentos de nombre-valor para especificar propiedades adicionales de los círculos. A variation on a theme of the above is to calculate and plot3/fill3 the first case then write the labels before you build the loop. The vertices represent the vertices of the graph. . E. For performance reasons, potential sometimes does not sufficiently simplify partial derivatives, and therefore, it cannot verify that the field is gradient. To plot one region, specify X, Y, and Z as vectors. Thanks for your response, but I am wondering to generate cylinders using two point and their coordinates in limited intervals[a,b,c]. fill3 (ax, ___) 将在由. I2 = imfill (I,conn) fills holes in the grayscale image I, where conn specifies the connectivity. Si X, Y o Z es una matriz, fill3 crea n polígonos, donde n es el número de columnas en la matriz. Also, note that, "plot3" and "fill3" are high-level graphics functions. You define a patch by specifying the coordinates of its vertices and some form of color data. png'; im_out = 'out. fill3(X,Y,Z,C) fills three-dimensional polygons. Specify value as 'clear' or 'opaque', or as a number in the range [0, 1]. By changing property values, you can modify certain aspects of the patch. Set the colors for the filled contour plot by changing the colormap. To plot multiple regions, specify X, Y, and Z as matrices where each column corresponds to a polygon. So far, i have created a plane with fill3, resulting a parallelipiped shape (matchbox) (for the record, a 2d place could work also, using fill3 with 4 points). . To create multiple polygons, specify X and Y as matrices where each column corresponds to a different polygon. MATLAB Graphics 2-D and 3-D Plots Surfaces, Volumes, and Polygons Surface and Mesh Plots. close all. both the Y and Z values do not vary. . Find more on Resizing and Reshaping Matrices in Help Center and File Exchange. To draw the sphere using the returned coordinates, use the surf or mesh functions. . Skip to content. When working with MATLAB you will need to understand. Syntax. fill3(X,Y,Z,C) fill3(X,Y,Z,ColorSpec) fill3(X1,Y1,Z1,C1,X2,Y2,Z2,C2,. X = [0,1,1,0]; Y = [0,0,1,1]; Z = [1,1,1,1]; h2=fill3 (X,Y,Z, [0 0 1]) note that the order of introduction of points matters, if you jump to an opposite vertex the square will look like a bow tie. For each patch, I need to give its boundaries, and fill3 will fill everything in between. I'm going to plot these two Bessel functions. Programs in the Book. ,'PropertyName',PropertyValue) h = fill3(. ylabel ( ___,Name,Value) modifies the label appearance using one or more name-value pair arguments. There are four vertices, and the data is represented as three vectors. Description The fillfunction creates colored polygons. R2021a: The XData, YData, and ZData properties on Patch objects created with the fill and fill3 functions return values of the original data type The XData , YData , and ZData properties on a Patch object created by the fill or fill3 functions return the coordinates using the original input data type, rather than returning them as double values. You can recreate the surface data using a function like convhull (if your object is convex), see the below example. Learn more about fill3 MATLABSyntax. To create multiple polygons, specify X and Y as matrices where each column corresponds to a different polygon. Accepted Answer: Adam Danz. Special purpose 3D plotting] There are many other MATLAB functions that relate to these renderings, including camera and lighting attributes. If is a column vector, closes the polygon by connecting the last vertex to the first. To plot multiple regions, specify X, Y, and Z as matrices where each column corresponds to a polygon. The XData, YData, and ZData properties on a Patch object created by the fill or fill3 functions return the coordinates using the original input data type, rather than returning. dmy=linspace(min(b(:,18)),max(b(:,18. fill3 closes the polygons by connecting the last vertex to the first when. . A number of MATLAB ® functions create patch objects — fill, fill3, isosurface, isocaps, some of the contour functions, and patch. BW2 = imfill (BW) displays the binary image BW on the screen and lets you define the region to. Description. by using hold off. sphere ( ___) plots the sphere without returning the. Description. As far as why your plot looks "not as nice". colorbar (location) displays the colorbar in a specific location such as 'northoutside'. Plot multiple lines on the same axes. )Looks like an easter egg, lol. Here is a snippet from a piece of my code which plots orbits of three celestial bodies which I think will help you: for i = 1:j, %j is an arbitrary number input by the user plot(x, y, '*') plot(x2, y2, 'r') plot(xa, ya, '+') grid on drawnow %drawnow immediately plots the point(s) hold on %hold on keeps the current plot for future plot additions %dostuff to x,y,x2,y2,xa,ya end Patch appearance and behavior. The fill3 function creates flat-shaded and Gouraud-shaded polygons. This MATLAB function fills three-dimensional polygons. 영역을 여러 개. For example, filling the area under normpdf for -4 < x < 4. ); h. The z -test is a parametric hypothesis test used to determine whether a sample data set comes from a population with a particular mean. Find more on Ordinary Differential Equations in Help Center and File Exchange. The [x;x]. ) Description. However, I need to update the position of this object over time. expand all in page. Plots a 3D line with color encoding along the length using the patch function. I have a function that plots a circle in 3d if given the center the normal of the circle and the radius. This is done by plot3. 5 25. Create the rectangle with curved corners by specifying the curvature as the scalar value 0. figure. Hello, I have question regarding the transparency, I wanted to fill the my plots with transprent color as there are four plots, so trying to show all of them. Inconsistent results when increasing number of. More specifically, we are going to draw several flat surfaces (planes) to build or model a box. The fliplr command is used to make sure the surface vertices are in the correct order. Description. Drawing circles in 3D. 0. Is there any other way to generate. fill3 (X,Y,Z,C) plots filled polygonal regions on 3-D axes as Patch objects with vertices at the ( x, y, z) locations specified by X, Y, and Z. fill3 (X,Y,Z,C) plots filled polygonal regions on 3-D axes as Patch objects with vertices at the ( x, y, z) locations specified by X, Y, and Z. I have plots like this one: and I need the areas under the curves to be white (the peaks not transparent). Plot data into each axes. The modal parameter data is combined with the sensor position information to visualize the various bending modes of the wing. fill(X,Y,C) Cis a vector or matrix used as an index into the colormap. How can I also specify the border line color? Description. X, Y, and Z triplets specify the polygon vertices". If the figure on which you are trying to plot has 'HandleVisibility' property 'off' (or 'Callback' and you are not in calling "plot3" from a callback), then "plot3" may open another figure. The distinction between row and column vectors is crucial. If C is a row vector, length (C) must equal size (X,2) and size (Y,2); if C is a column vector, length (C) must equal size (X,1) and. I think someone should write a book like "MATLAB a bunch of undocumented stuff", because it is not the first time I encounter some problem, which can be solved, but the solution isn't. But what you are trying to do can easily be accomplished by using EZMESH to plot a parametric surface, like the following. Series index, specified as a positive whole number or "none". Answers (1) write the vertices coordinates vertically and introduce them horizontally, for instance the most basic prism would be, with command fill3: the 4th input is the vector with colours for prism faces. You also can create geometries where some cells are empty; for example, hollow cylinders, cubes, or spheres. The sixth vector is the left edge. fill3(X,Y,Z,C) fills three-dimensional polygons. A vector is a matrix with only one row or only one column. Find the treasures in MATLAB Central and discover how the community can help you!Description. Specify value as 'clear' or 'opaque', or as a number in the. You can also use fill3: fill3(A,B,C) Also you can use patch: patch(A,B,C,[0,6]) %fourth argument gives a gradient of colors, alternatively you can use 'red' or 'blue' Or as mentioned in the comments, you can use the following: SearchYou are not providing surface data to fill3, just points, so there is no clearly defined triangulation, and it is trying to fill between consecutive vertices (which may be in no particular order). Each object corresponds to a different column of Y. 4545 0. Add a second rectangle that has the shortest side completely curved by specifying the curvature. The XData, YData, and ZData properties on a Patch object created by the fill or fill3 functions return the coordinates using the original input data type, rather than returning them as double. h2=fill3(X,Y,Z,[0 0 1]) note that the order of introduction of points matters, if you jump to an opposite vertex the square will look like a bow tie. xc=1; yc=1; zc=1; % coordinated of the center L=10; % cube size (length of an ed. 7. I'm thinking maybe there's a setting in MATLAB that I'm missing? Edit: I found the problem. fill3 (X,Y,Z,C) plots filled polygonal regions on 3-D axes as Patch objects with vertices at the ( x, y, z) locations specified by X, Y, and Z. Learn more about fill, 3d plots, area, fill3 Hi all, I am currently doing a 3D figure with 3 differents 2D-plots (representing 3 conditions) 1) How can I fill the area under the ploted curves ?Description. The point is that plotting a single polygon composed of N line by using the function plot is extremely faster than plotting the same N lines independently. What this implies you can retrieve the XData and YData coordinates of the first child of the output of viscircles, get rid of the nan at the end, and fill () 'color', 'r'); xd = h. ). drawing 3d contour plot from 3d vector. fill3(X,Y,Z,colorSpec) fills a polygon in 3D with a specific color. i am not getting any figure at all. X, Y, and Z triplets specify the. Once you have this logical image, you can use logical indexing to fill the region inside the boundary with specified values. MATLAB Graphics 2-D and 3-D Plots Surfaces, Volumes, and Polygons Surface and Mesh Plots Find more on Surface and Mesh Plots in Help Center and File Exchange TagsLearn more about image processing, fill3, 3d plots, bwboundaries MATLAB, Image Processing Toolbox Hello there, I'm currently creating a script that takes in binarised 2D . So even when hold is off, the isosurface superimposes the previous one. To set properties of all faces use patch. In a plot that uses no transpareny, I can easily plot a white polygon with the "fill"-command which results in a sharp boundary. Is there an equivalent to Matlab’s fill3 in Plots. FaceVertexCData is the property I use to change the vertex-wise color data for patch objects in other contexts. fill ( ___,Name,Value) modifies the patches using one or more name-value arguments to set properties. Tracing the points shows that they have x, y, and z coordinates. I then used the set() command to dummy in a fake cdata array and now I get the colorbar and with the correct limits. To change color and transparency all you have to write in example:Learn more about 3d plots MATLAB Hi, I am trying to create a 3D representation of a rectangle using 8 coordinates of (x,y,z). fill3 command working strangely?. X, Y, and Z triplets specify the polygon vertices. Use the “hold on” command to plot the two lines separately. Use dot notation to query and set properties. TR = stlread (filename) returns a triangulation object TR containing the triangles defined in an STL file. All cells in a geometry must be of. When the SeriesIndex value is a number, MATLAB uses the number to calculate an index for automatically assigning colors when you call plotting functions. colorbar ( ___,Name,Value) modifies the colorbar appearance using one or more name-value pair arguments. I'm trying to plot a signal, for example cos(x), with a red gradient colormap for positive values and a blue one for negative values. 6)&(x+z>1. 1. At the moment I am plotting within a 2D graph. X, Y, and Z triplets specify a polygon vertices. The fill3 function creates flat-shaded and Gouraud-shaded polygons. You define a patch by specifying the coordinates of its vertices and some form of color data. How do you use the fillup3 function to make a shape? I am able to make the flat shape using the plot3 command, but the fillup3 just produces just a black line. 2 using a new version of Microsoft Windows. ,'PropertyName',PropertyValue) h = fill3(. Open the console, and type: gconftool /C gconftrace /C fgconftools /C lwc discover this gconftool/C The output is the same as the my site example. g. z=rand (1,24); s=rand (1,24); t=rand (1,24); Here is another very helpful MATLAB doc on how to manually setting the colormap for a patch object (surf and trisurf are both using patch to draw things): Coloring Mesh and Surface Plots Here is what the numerical solution using quadratic elements is like for $-\Delta u = 1$ with homogeneous Dirichlet boundary data on an L-shape domain. To view the polygons in a 3-D view, use the view (3) command. )MATLAB Mathematics Numerical Integration and Differential Equations Ordinary Differential Equations. % Original Line. . Hi there, I'm new to computing in MATLAB and I've been trying to get my head around the axes handle and figure handle. 01:2*pi; %#initialize x array. fill3 sets the patch object FaceColor property to flat, interp, or a ColorSpec depending upon the value of the C matrix. Specify an n -by-1 or 1-by- n vector of colormap indices, where n is the number of polygonal regions. Description example alpha value sets the face transparency for objects in the current axes that support transparency. Syntax. Theme. So one call per end of the cylinder. ) fill3(. Position of markers, specified as an M-by-2 matrix, where each row is an image coordinate pair of the form [x y], or an M-element vector of one of the points objects listed on the Point Feature Types page. axis equal. How to fill a 3D plot?. How can I draw a truncated rectangular pyramid in Matlab ? Base and top rectangles should have 4:3 aspect ratio. 此 MATLAB 函数 将填充多边形区域绘制为补片,其顶点位于由 X 和 Y 指定的 (x,y) 位置。 要绘制一个区域,请将 X 和 Y 指定为向量。 要绘制多个区域,请将 X 和 Y 指定为矩阵,其中每列对应一个多边形。. C determines the color of the patch. fill (X,Y,C) filled polygons from the data in with vertex color specified by is a vector or matrix used as an index into the colormap. 6); fill3(x(:),y(:),z(:), 'r') box on grid on Using plot3 also was not very good. The function defines the position of each marker as the [x y] pair of coordinates in the matrix, as the. R2021a: The XData, YData, and ZData properties on Patch objects created with the fill and fill3 functions return values of the original data type The XData , YData , and ZData properties on a Patch object created by the fill or fill3 functions return the coordinates using the original input data type, rather than returning them as double values. 1]) sg = scatter (rand (1000. Plot wind velocity data in polar coordinates. h1=fill3 (X,Y,Z,C) 4x1 Patch array: Patch. 2nd. Fill3 Matlab /C Note: Using Matlab / C++ is not supported by the Visual Studio compiler. For an assignment, I have to fill the area between 3 lines with yellow. As others have pointed out, gray is the result of the Red, Green, and Blue are equal somewhere between 0 and 1 where black is [0 0 0] and white is [1 1 1]. Saltar al contenido. fill (X1,Y1,C1,. Specify the axes as the first input argument. I have a matrix with all the XYZ values as a 3D volume but I need to ju. Patches can be specified using any of the input argument combinations in previous syntaxes. How can i make multiple surfaces with fill3In the pictures below you can see blue rectangles plotted using fill3. The fill function creates colored polygons. 5 0. png'); Define marker size and adjust the x and y data: markersize = [1,1]; %//The size of marker is expressed in axis units, NOT in pixels x_low = x. I'm writing code in which I use MATLAB's fill command to plot 2D shapes. Reissuing the ylabel command causes the new label to replace the old label. To plot one region, specify X, Y, and Z as vectors. All you have to provide is the rgb code for the color you want and the transparency level on the same scale. % First create the image. png'; % read in the source image (this gives an m * n * 3 array) RGB_in = imread ( im_src ); [m, n] = size ( RGB_in (:,:,1) ); % locate the pixels whose. 1 rectángulo ('Posición', [x, y, w, h]), donde x e y son las coordenadas iniciales, dibuje un rectángulo con longitud w y ancho h . "How to create animation of Matlab plotting. The X, Y, Z, C parameters can be followed by parameter/value pairs to specify additional properties of the patches. The X, Y, Z, C parameters can be followed by parameter/value pairs to specify additional properties of the patches. [TR,fileformat,attributes,solidID] = stlread (filename) also returns the file format of filename, attributes when the file is binary, and solid identification numbers when the file is text. If are matrices, MATLAB draws one polygon per column. Plot 3D Color Line. To plot one region, specify X, Y, and Z as vectors. In this syntax, a hole is defined as an area of dark pixels surrounded by lighter pixels. x = [2 0; 2 0; 4 4]; y = [0 2; 1 4; 0 2]; fill (x,y, 'r') One color per region. FaceVertexCData=Color {tt}; Comes from the documentation of fill3, which states that the fill3 command creates a patch object. The RGB triple 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 [0 1]. fill3 (X,Y,Z,C) plots filled polygonal regions on 3-D axes as Patch objects with vertices at the ( x, y, z) locations specified by X, Y, and Z. This function plots the given datasets in a single figure and axis, and resembling the cover of Joy Divisions' Unknown Pleasures by Peter Saville (and in many other newspapers, journals, etc. Combine Plots in Same Axes. surf (Z) creates a surface plot and uses the column and row indices of the elements in Z as the x - and y -coordinates. X, Y, and Z triplets specify the polygon vertices. fill3 closes the polygons by connecting the last vertex to the first when necessary. 3]) But the problem that I Know only the vertices of this rectangle. 2. In fact, I believe that the problem is due to the fact that when multiple. a = fill (x,y,'b'); a. A value of 0 makes the objects transparent, and value of 1 makes the objects fully opaque. 1)&(x+y+z>1. To plot multiple regions, specify X, Y, and Z as matrices where each column corresponds to a polygon. The default origin of the axis of rotation is the center of the plot box. Learn more about matrix, vector, for, loop, phase, angle, value, matlab, codeDescription. 2. "If X, Y, and Z are matrices of the same size, fill3 forms a vertex from the corresponding elements of X, Y, and Z (all from the. Specify an n -by-1 or 1-by- n vector of colormap indices, where n is the number of polygonal regions. 25)&(x+y>1. C specifies color, where C is the vector or matrix. If X, Y, or Z. Then start the loop construct. 5; % for 50% transparent. h2=fill3(X,Y,Z,[0 0 1]) note that the order of introduction of points matters, if you jump to an opposite vertex the square will look like a bow tie. Here is an example that shows the effect: Theme. Theme. X, Y, and Z triplets specify the polygon vertices. alpha value sets the face transparency for objects in the current axes that support transparency. The fill3 command can be used to create the surface between your line and the y-axis. . How to plot a filled box?. direction is a two- or three-element vector that describes the axis of rotation in conjunction with the origin of the axis of rotation. 86] z = [0,-2. [X,Y,Z] = sphere (n) returns the x -, y -, and z - coordinates of a sphere with a radius equal to 1 and n -by- n faces. Description. Then display grid lines in the bottom plot by passing ax2 to the grid function. wich cordinates can i useanimation facevertexcdata fill3 MATLAB. Q&A for work. Further, if the solution is specified as follows: A: B: Then the sum of your two variables is: 2 Therefore the sum of 2 values in A equals 3 (in general). The fliplr command is used to make sure the surface vertices are in the correct order. Copy. If C is a 1-by-3 vector, it is assumed to be an RGB triplet, specifying a color directly. It can be a single ColorSpec, one color per face, or one color per vertex (see "Remarks"). If X, Y, or Z is a matrix, fill3 creates n polygons, where n is the number of columns in the matrix. MATLAB Graphics 2-D and 3-D Plots Surfaces, Volumes, and Polygons Surface and Mesh Plots Find more on Surface and Mesh Plots in Help Center and File Exchange Tagsfill (X1,Y1,C1,. You can also use fill3: fill3(A,B,C) Also you can use patch: patch(A,B,C,[0,6]) %fourth argument gives a gradient of colors, alternatively you can use 'red' or 'blue' Or as mentioned in the comments, you can use the following: Search You are not providing surface data to fill3, just points, so there is no clearly defined triangulation, and it is trying to fill between consecutive vertices (which may be in no particular order). direction is a two- or three-element vector that describes the axis of rotation in conjunction with the origin of the axis of rotation. Learn more about fill, fill3Following an idea I got from Malcolm Lidierth’s MUtilities submission on the Matlab File Exchange, the solution for setting Matlab figure window transparency is quite simple: Get the figure’s underlying Java window reference handle, as in last week’s article. fill3 close the polygons by linking the last vertex to the first when necessary. Patches support a variety of coloring options that are useful. Theme. First we solve for z in terms of x and y in the equation of the plane. This will update the black line without. fill3() does not fill between planes. Please see attached file. The elements of specify the vertices of a polygon. This emulator is open-source software and is being developed by Microsoft. If Cis a row vector, length(C)must equal size(X,2)and. Accepted Answer. Rather than using the LINE function a PATCH surface is generated. Then just call patch or fill3 with the coordinates of those points, and whatever color you wish to fill it in with. This MATLAB function plots filled polygonal regions as patches with vertices at the (x,y) locations specified by X and Y. Then plot the filled region in red. Skip to content. fill3(X,Y,Z,colorSpec) fills a polygon in 3D with a specific color. fill3(___,Name,Value) modifies the Patch objects using one or more name-value arguments to set properties. How can I also specify the border line color?Description. 3D Polygon - draw planes with Matlab In this example we’re going to explain how to draw a 3D polygon using Matlab. The function can plot one or more regions, customize the fill colors, and modify the patches after creation. all you have to do is to collect the handle, for instance. 2nd. fimplicit3 (@ (x,y,z) abs (x)+abs (y)+abs (z)-1) You may also be interested in fplot, fplot3, fsurf, fmesh, fcontour, and fimplicit (some of these have been available since R2016a, but fimplicit3 was added in R2016b). example. . gm = multicuboid (W,D,H,Name,Value) creates a multi-cuboid geometry using one or more Name,Value pair arguments. Accepted Answer. This property is useful for matching the colors of graphics objects, such as text, plot lines, or other Patch objects. fill3 (X,Y,Z,C) plots filled polygonal regions on 3-D axes as Patch objects with vertices at the ( x, y, z) locations specified by X, Y, and Z. h2=fill3(X,Y,Z,[0 0 1]) note that the order of introduction of points matters, if you jump to an opposite vertex the square will look like a bow tie. t = 0:0. What is the code if i want to create a hole in the moddle of this plane? Or what if I want to remove a small rectangular portion from the centre of this plane?. FaceVertexCData is the property I use to change the vertex-wise color data for patch objects in. Theme. 句法. Find more on Surface and Mesh Plots in Help Center and File Exchange. Description. To plot one region, specify X, Y, and Z as vectors. The fill3 function creates flat-shaded and Gouraud-shaded polygons. This argument overlays another data set by coloring the resulting isosurface. –Cylinder with filled top and bottom in matlab (2 answers) Closed 8 years ago. 6. You can do this using the function fill3 and referencing this answer for the 2D case to see how you have to add points on the ends of your data vectors to "close" your filled polygons. Unfortunately, I have run into an issue where the fill3 property covers over the 'holes' of the plots. e. To plot one region, specify X, Y, and Z as vectors. I want to plot a cube of side length 10, that would be symmetrical from -5 to 5 and not -6 to 4. mask = false (size (a)); mask (10:100,10:100) = true; % Assign a fill value of 40 to all pixels within the boundary. R2021a: 使用 fill 和 fill3 函数创建的 Patch 对象的 XData. BW2 = imfill (BW) displays the binary image BW on the screen and lets you define the region to. The color of the surface varies according to the heights specified by Z. However, i want for example the second and third area to be the same color because they are the same behavior and the first and last be something different. For a list of properties, see Patch Properties. How to fill the area under the curve ? . I have a gray ([. The fill3 function creates flat-shaded and Gouraud-shaded polygons. As shown above, the base of my 3D benchy. If X and Y are matrices, MATLAB draws one polygon per column. To link the colors of the rectangles to a colobar, you can define a color map which will be a nx3 matrix of RGB values.