Matlab Plot Color Legend

Matlab Plot Color LegendMapping and Plotting Tools. In this tutorial, we will discuss how to add custom legends to the plot using the legend() and text() function in MATLAB. Polar properties control the appearance and behavior of the polar plot function object. By changing property values, you can modify certain aspects of the legend. It seems this is making the plot function return a column vector of Line objects and this is why I am getting the multiple legend entries. When you plot a two dimensional array, you ordinarily get a bunch of lines, colored like this. We can also use it to overlay meta-data information, such as buy/sell. Defining legend for pcolor plots in MATLAB. Adding Non-Plotted Items to Figure Legend. The graph has two legends and plotted from a big loop. x=linspace (-1,1); plot (x,2*x, x,4*x, x,6*x, x,8*x, x,10*x, x,12*x, x,14*x, 'LineWidth', 2) legend ( 'color 1', 'color 2', 'color 3', 'color 4', 'color 5', 'color 6', 'color 7', 'Location', 'SouthEast' ) title ( 'Default colors' ). I'm not sure fill has a way to use the traditional legend, so here's what I'd try: After each graph create dummy plots and use their colors to be the same as your fill objects and then use the regular legend: hold on L1 = plot (NaN,NaN,'r',NaN,NaN,'b',NaN,NaN,'y'); legend (L1,'inflation', 'interest rate' ,'exchange rate'); to set the. L=legend (label of the legend 1label of the legend N): This includes the legend labels. Defining legend for pcolor plots in MATLAB. This is a 2-element numeric array specifying the minimal size of the legend entries’ icon and label. You're plotting 20 rows of data, yet you're only passing in 2 legend strings. Matlab plot markers with color and transparency gradients This can be useful for plotting comet trails, radar/sonar tracks, travel trajectories, etc. Use scatter with the optional parameter c to plot the points with the interpolated colors. The plot() function is used to draw points (markers) in a diagram. Next, we will define B as the cos function of values of A and C as sine function of values of A. Different color and different legend for each iteration (MATLAB). For each line in the plot, the legend shows a sample of the line type, marker symbol, and color beside the text label you . The main difference between them is, in the surface plot, the connecting lines and the faces both will be displayed in the dark color. Plot line colors and legend colors don't match. Change the line color to a shade of blue-green using an RGB color value. Legends are a useful way to label data series plotted on a graph. To fix, it's probably easiest to just plot each row one at a time. Use only cyan star markers for the third sine curve. Maybe this code helps you: x = 1:. Use a green line with no markers for the first sine curve. To change the legend text colors individually, you have to first get the handles to the text objects, which are children of the legend object. The following are the letters you can add to your code to control the color of your plot while plotting in Matlab. If the handles, hobjs , are not specified . Additionality i want a color scale that shows the relationship between the colors and the values. For each line plotted, the legend shows a sample of the line type, marker symbol, and color beside the text label you specify. This could go some way to explaining why greater numbers of movie posters and DVD covers are being illustrated. clear; clf; syms gamma_voc (voc); % gamma wrt v/c. The following plots 2 data sets nicely. Set the DisplayName property as a name-value pair when calling the plotting functions. Specify Plot Colors MATLAB ® creates plots using a default set of colors. Persisting transparent colors in HG2 – We can set semi- and fully-transparent colors in HG2 for multiple graphic objects, but making these settings stick is non-trivial. I'm trying to do something on R2019b and for some reason my plots legends are bugged. Specify Plot Colors MATLAB ® creates plots using a default set of colors. Return the bar object as b, so you can customize other aspects of the chart later. It could also be another color or the. This is how our input and output will look like in MATLAB console: Code: A = 2*pi : pi/50 : 3*pi B = cos (A) C = sin (A) figure plot(A,B,A,C) legend. It could also be another color or the whole color scheme. Then, use lgd with dot notation to set properties, such as lgd. Then, call the legend command to create the legend. 3" is yellow and the others some color in between. a = sin (X) b = cos (X) [Defining 100 equally distant points] [Defining our first function: sin function] [Defining our second function: cos function] Note: For this example, we will be creating our. Use name-value pairs in the legend command. x = rand (1,100); y = rand (1,100); scatter (x,y,75, 'MarkerEdgeColor', 'b',. I have a color scheme for the bubbles, and I am trying to create a custom legend showing what the color scheme means. ColorData (4) – this returns a uint8 number between 0-255. How to create the Surf plot in MATLAB? Syntax: In the surface plot, ‘surf’ function is used. Color can make it easier for people to identify important information, such as legends on an Excel graph. RGB Triplet Hexadecimal Color Code Appearance [0 0. Now you can use this handle h as the first argument of your legend function. To change the legend text colors individually, you have to first get the handles to the text objects, which are children of the legend object. Create a legend according to the colors of a Learn more about legend, color, colormap, plot MATLAB. Available buttons will vary by plot/legend type. Matlab plotting colors. You can learn more about this topic at matwork. ItemTokenSize == [30,18], but we can either expand or. Specify Line Style, Color, and Marker Plot three sine curves with a small phase shift between each line. MATLAB ® creates plots using a default set of colors. Specify the legend labels during the plotting commands by setting the DisplayName property to the desired text. I'm trying to do something on R2019b and for some reason my plots legends are bugged. I'm not sure fill has a way to use the traditional legend, so here's what I'd try: After each graph create dummy plots and use their colors to be the same as your fill objects and then use the regular legend: hold on L1 = plot(NaN,NaN,'r',NaN,NaN,'b',NaN,NaN,'y'); legend(L1,'inflation', 'interest rate' ,'exchange rate'); to set the location of the legend see the documentation, for example: legend(L1,'inflation', 'interest rate' ,'exchange rate','Location','SouthOutside','Orientation. With legend calls, you need to make sure all of your plots are there in one function call before you call legend. dataset1=rand (10,3); dataset2=rand (10,4)*10;. h2 = plot (dataset2,'color','r') legend ( [h1 (1), h2 (1)], 'DATASET1', ' DATASET2') This is telling legend that you want one entry for the first item from the first call to plot (i. Examples to Implement Matlab Plot Legend Let us understand the function with an example: Example #1 First, we will define 'A' as a vector containing values between 2pi (π) and 3π. The color legend can either be categorical or quantitative. A surface plot is somewhat similar to a mesh plot. How to Set Color of Scatter Plots? For this example, we will scatter plot of red color Syntax: a = linspace (0, 2*pi,100) b = cos (a) + rand (1, 100) scatter (a, b, 'r') [Defining 100 equally distant points] [Defining our cos function] [Plotting our scatter plot]. since I have 2 plots and 2 lines. Plot line transparency and color gradient. Legend function in MATLAB allows us to put our label in place of our choice. % This file plots gamma as a function of v/c as well as some of its Taylor. What Is the Definition of Plot Structure?. In most cases, when you use name-value pairs, you must specify the labels in a cell array, such as legend({'label1','label2'},'FontSize',14). It is not showing the color coded key in the legend although it will show the label text. Adding Non-Plotted Items to Figure Legend. I'm trying to plot the cumulative sum of a series against the infinite sum, and can't get the colors in the legend to match those on the graph. Plot Legends in MATLAB/Octave. Add Custom Legends Using the legend() Function in. And the following example plots the color bar below the map and adds its label using legend_kwds : >>> # Plot population estimates with an accurate legend . How to Plot MATLAB Graph with Colors, Markers and …. When you specify CData (the color input) for scatter, MATLAB uses colormapping to plot the data, and a colorbar to describe the mapping. Afterward, I manually added black lines in the figure window representing the angles where peak. L=legend (label of the legend 1…label of the legend N): This includes the legend labels in the graph as specified in the labels argument. Editing colors in the legend. h1 (1)) and another entry for the first item from the second call to plot (i. You can either plot NaN values in the figure, which will not directly show up in the figure, or you can create a Line object and set its 'Visible' property to 'off'. The legend updates automatically whenever we include any new or remove data series from the current axes. The legend () function in MATLAB/Octave allows you to add descriptive labels to your plots. The size and shape of the circle marker will not change when you resize the figure. This is because the graph is in big loop. For the labels, the legend uses the text from the DisplayName properties of the . In addition, k is a vector while G is a single number. dataset1=rand(10,3); dataset2=rand(1. x=linspace (-1,1); plot (x,2*x, x,4*x, x,6*x, x,8*x, x,10*x, x,12*x, x,14*x, 'LineWidth', 2) legend ( 'color 1', 'color 2', 'color 3', 'color 4',. MATLAB® cycles the line color through the default color order. You're plotting 20 rows of data, yet you're only passing in 2 legend strings. Add Custom Legends Using the legend () Function in MATLAB The legend () function is used to add legends to a plot in MATLAB. And then we simply write ‘legend’ in our code to get the labels. Use interp1 to interpolate between the values in the RGB space using your data by setting the first color as the lowest value and the last color as the highest value. Legend does pick up line colors, styles, markers, and so on. Plot x and y using plot() method, where color of line is red and label is "y=exp(x)". And then we simply write ‘legend’ in our code to get the labels. This is how our input and output will look like in MATLAB. I am plotting 6 data vectors and a legend. The first 4 components of the legend have the correct color (matches the plotted colors). It's easy to add a variety of elements to a movie poster through portraiture, colour schemes and composition. The default colors provide a clean and consistent look across the different plots you create. The legend () function in MATLAB/Octave allows you to add descriptive labels to your plots. plot (dataset2,'color','r') legend ('DATASET1', ' DATASET2') Accepted Answer Thorsten on 9 Jul 2015 2 Link Translate Edited: Walter Roberson on 13 Oct 2015 You can create each plot with a handle hi, of which you store only the first entry in h. Alternatively, you can specify the legend labels using the DisplayName property. The vertical offset (relative to the font size) for the markers created for a scatter plot legend entry. The solid lines with dots have B=10 and dashed with Xs B=20. The MarkerEdgeColor property controls the outline color, and the MarkerFaceColor controls the fill color. Is there any way to change the color of lines in the legend AFTER plotting the graph(like using Edit\axes properties)? . Learn more about gscatter, legend control MATLAB, Statistics and Machine Learning Toolbox Hi. In this video, steps to edit font, edit y limit, insert arrow, change color, edit y label, and edit ticks in MATLAB Figure are . However the legend colors is not the same as the plot colors, even though they are in order. Note: For this example, we will be creating our functions in following colors: 1 st function in Green, 2 nd function in Blue and 3 rd function in Yellow] example: plot (X, a, ‘g’, X, b, ‘b’, X, c, ‘y’) [Plotting our functions] Observe in the code that we have passed pre-defined color codes as arguments (Please refer to the table at. For the examples in this section, we will generate a sample figure using the following code. Legend Properties Legend appearance and behavior expand all in page Legend properties control the appearance and behavior of a Legend object. Also, the plot reused the same blue color (at least) twice. Specify Color of a Bar Chart Copy Command Create a red bar chart by calling the bar function and specifying the optional color argument as " red". 1:2*pi; colors = jet(5); for n = 1:5 plot(x,sin(x)*n,'color',colors(n,:),'DisplayName',strcat('param=' . Today I’d like to introduce a guest blogger, Jiro Doke (email: Jiro. The basic syntax is: legend ( ‘Description 1’, ‘Description 2’, … ). Use a blue dashed line with circle markers for the second sine curve. I have a color scheme for the bubbles, and I am trying to create a custom legend showing what the color scheme means. The objects returned by these functions typically have properties for controlling the color. He used MATLAB in his life prior to The MathWorks, and one of. I have a code that generates a plot of the coefficient of variation for torque generated over a certain range of motion (knee joint angle of 30-85°) by an injured leg in red and the uninjured leg in blue. How to change change color of line or patch in legend. Many plotting functions have an input argument such as c or colorspec for customizing the color. Set the DisplayName property as a name-value pair when calling the plotting functions. It is not showing the color coded key in the legend although it will show the label text. Walter Roberson on 21 Jun 2011. Afterwards you have to call only legend, without . So it takes the colors of those two from the first two that you plotted, which . x = linspace (0,pi); y1 = cos (x); plot (x,y1, 'DisplayName', 'cos (x)' ) hold on y2 = cos (2*x);. These examples show how to create a legend and make some common modifications, such as changing the location, setting the font size, and adding a title. Use dot notation to refer to a particular object and property:. As such, combine your plot of the normal geometric series with its cumulative sum together in one function call, and then call legend accordingly. One way to create a legend containing the colors of the contours is to create invisible lines with the colors of the contour plots. legend (MATLAB Function Reference). I am having difficulty finding a convenient way to plot a circle and simply place it at a desired location relative to the figure. Using a color scale on a plot. This would generate a n*3 matrix where n is the number of data points. Surface 3D Plot in MATLAB. Setting line colors in legend of MATLAB plot?. Does that make sense? Sign in to comment. Then, call the legend command to create the legend. Plot two lines. Arduino Real Time Plotting With Matlab: Analytics is one of the best tools which help you gain information about what is happening, and help you to see the trends in the data. So it takes the colors of those two from the first two that you plotted, which were in blue color. colors = ["red", "blue"]; labels = ["this is red", "this is blue"]; % We 'plot' a invisible dummy point. The simplest way to use the function is to pass in a character string for each line on the plot. We can mention the label in the form of strings or characters. MATLAB ® creates plots using a default set of colors. I am trying to annotate a bubblechart (R2022b) that is on a semilogy scale. Working of Matlab Legend In Matlab, legends are used to label the plotted data for every parameter that is mentioned. In order to fit with a global colororder scheme, I need to change the color of my surface plot after I have created it. The general syntax to display the 3D plot is, plot3(x,y,z) plot3(x,y,z,Name) plot3(x,y,z,LineSpec) Let’s start drawing different types of the 3D plot graph…. html/RK=2/RS=wSvirrPbzPnJ4zd6IPS0cQIks9I-" referrerpolicy="origin" target="_blank">See full list on mathworks. Scatter is thinking of CData as. You must have at least three plot s in each plotgauss2d plot. Many plotting functions have an input argument such as c or colorspec for customizing the color. To change the legend text colors individually, you have to first get the handles to the text objects, which are children of the legend object. Professional designers learn to use color coding . When plotting filled areas (patch . Our inputs A, B& C are first passed as arguments to the function ‘plot’. Specify the marker size as 75 points, and use name-value arguments to specify the marker outline and fill colors. To control the appearance of legend entries, plot points that have values which are NaN then pass the objects returned by plot and an array of labels to the legend function ( NaN points are not visible in the plot, but appear in the legend). So it takes the colors of those two from the first two that you plotted, which were in blue color. So it takes the colors of those two from the first two that you plotted, which were in blue color. x1 = linspace (0,5); y1 = sin (x1/2); plot (x1,y1, 'DisplayName', 'sin (x/2)' ) hold on x2 = [0 1 2 3 4 5]; y2 = [0. You're plotting 20 rows of data, yet you're only passing in 2 legend strings. The problem here is there are 6 possible postures, but not all the postures will be covered for a given accelerometer dataset. Use dot notation to refer to a particular object and property: plot (rand (3)) lgd = legend ('a','b','c'); c = lgd. At the end there are same colors (both blue) for both lines which represented in the legend box however the data itself are in blue and red. I am having difficulty finding a convenient way to plot a circle and simply place it at a desired location relative to the figure. Matlab legend() not showing line color. b blue; g green; r red; c cyan. Many plotting functions have an input argument such as c or colorspec for customizing the color. The first subplot shows 3-axis accelerometer data (not relevant, just an example!) and the second plot shows the corresponding computed body postures in a pcolor plot. You can customize the colors if you need to. For example, in the plot below, blue lines have a value of A=1, and red is A=2. yeah maybe the problem is that. legend places a legend on a graph. 1 Answer Sorted by: 2 With legend calls, you need to make sure all of your plots are there in one function call before you call legend. This is a 2-element numeric array specifying the minimal size of the legend entries' icon and label. For the labels, the legend uses the text from the DisplayName properties of the data series. The line color used for legend() will be the same as the line color used on the graph. For example, legend (‘Mon. You're plotting 20 rows of data, yet you're only passing in 2 legend strings. Syntaxes that are used in Matlab: L=legend: This is used to include the legend in the plotted data series. Matplotlib is one of the most popular Python packages used for data visualization. p1 = plot(nan, nan, colors(1. Joseph Cheng on 8 Jul 2015 0 Link. Specify the legend labels during the plotting commands by setting the DisplayName property to the desired text. When I plot these functions and make a legend, the colors for the lines don't match the colors in the legend. Plot legend customization – Matlab plot legends and. Matlab legend () not showing line color. Matlab legend () not showing line color. I want to add a color scale so the function with the value "-10. Legend properties control the appearance and behavior of a Legend object. Legend properties control the appearance and behavior of a Legend object. Matlab & Simulink Tips # 1. Matlab Plot Colors and Styles. a legend for data organized into Learn more about legend, bar graph MATLAB. We will define an increment of π/50 between these values. This is a 2-element numeric array specifying the minimal size of the legend entries’ icon and label. Specify Color of a Bar Chart Copy Command Create a red bar chart by calling the bar function and specifying the optional color argument as " red". Function Reference: legend. Specify the legend labels during the plotting commands by setting the DisplayName property to the desired text. Is there a way to change the colors in the legend? Thanks a lot. Plot structure is the sequence of events in a story. Many plotting functions have an input argument such as c or colorspec for customizing the color. The legend () function in MATLAB/Octave allows you to add descriptive labels to your plots. change the color of data in legend. Syntaxes that are used in Matlab: L=legend: This is used to include the legend in the plotted data series. ItemTokenSize == [30,18], but we can either expand or shrink the icons/labels by setting different values. I already reinstalled Matlab and the problem persists. [0 0 0] (default) | RGB triplet | hexadecimal color code | 'r' | 'g' | 'b' |. You can then set MarkerSize, MarkerEdgeColor, and MarkerFaceColor as desired. rgb = get (gca, 'colororder' ) show_colors (rgb). You can customize the colors if you need to. com%2fhelp%2fmatlab%2fcreating_plots%2fspecify-plot-colors. At the end there are same colors (both blue) for both lines which represented in the legend box however the data itself. You cannot get the transparency component via the Color property, you need to use the line’s edge’s ColorData property instead: x = h2b. You can return the Legend object as an output argument from the legend function, such as lgd = legend. Syntaxes that are used in Matlab: L=legend: This is used to include the legend in the plotted data series. legend creates a legend with descriptive labels for each plotted data series. It is a cross-platform library for making 2D plots from data in arrays. Legends are a useful way to label data series plotted on a graph. This is even happening with old plots from homework from last year when. Polar properties control the appearance and behavior of the polar plot function object. Title, Text, Title of the legend, Visible, String, Color, FontSize, FontWeight. Legends are a useful way to label data series plotted on a graph. Using Basic Colors in Graphs ; blue, b, [0,0,1] ; black, k, [0,0,0] ; red, r, [1,0,0] ; green, g, [0,1,0]. Note: For this example, we will be creating our functions in following colors: 1 st function in Green, 2 nd function in Blue and 3 rd function in Yellow] example: plot (X, a, ‘g’, X, b, ‘b’, X, c, ‘y’) [Plotting our functions] Observe in the code that we have passed pre-defined color codes as arguments (Please refer to the table at. The graph has two legends and plotted from a big loop. 2, a little bigger that the width of a character. Arduino Real Time Plotting With Matlab : 3 Steps. By changing property values, you can modify certain aspects of the legend. Color Order for Line Plots » Cleve’s Corner: Cleve Moler on. In MATLAB, the plot3() function is used to draw the 3D plot graph. MATLAB Plot Colors to draw the Graph If you are drawing any picture on paper, you have different color pencils to use. If the DisplayName property is empty, then the legend uses a label of the form 'dataN'. n = 19; plot (magic (n), 'linewidth' ,2) title (sprintf ( 'magic (%d)' ,n)) The color of these lines is obtained by cycling through the "color order", which, by default, is these seven colors. The graph has two legends and plotted from a big loop. You can convert it into a 0-1 double value using (for example) double (h2b. Then you can change their text colors separately. Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB uses in many types of plots. You're plotting 20 rows of data, yet you're only passing in 2 legend strings. Adding Non-Plotted Items to Figure Legend. 6]; scatter (x2,y2, 'filled', 'DisplayName', '2016' ) legend. Just like it is to change the color of your plot in Matlab, the same goes for changing the line style, increasing the thickness of the line or some other aspect of it. What is the easiest way to plot a circle annotation that maintains its. You're plotting 20 rows of data, yet you're only passing in 2 legend strings. MATLAB® cycles the line color through the default color order. width, Width in characters of the legend strip. By changing property values, you can modify certain aspects of the legend. I’m attempting to color code the legend (group) entries in a group scatter plot using the following code: % Clear out all workspace variables and. Alternatively, you can specify the legend labels using the DisplayName property. although I'm showing 2 lines with one color but at the same time I need to have 4 texts and 4 colors in the legend. Create a scatter plot of random numbers. Legend not using the same colors as the plots?. Option to set the text color in legend to be same as the line #10720. 0980] "#D95319" then MATLAB passes the Legend object and an event data structure as the first and second input arguments to the function. There are Mini Toolbars dedicated to legend and color scale customization. To place the legend, use legend() method with location . Then you can change their text colors separately. “matlab plot legend” Code Answer's add manual legend matlab h1=plot([1:10],'Color','r','DisplayName','This one');hold on;. 5 MATLAB 3D Plot Examples Explained with Code and Colors. Also, the plot reused the same blue color (at least) twice. x = linspace (0,pi); y1 = cos (x); plot (x,y1, 'DisplayName', 'cos (x)' ) hold on y2 = cos (2*x); plot (x,y2, 'DisplayName', 'cos (2x)' ) hold off legend. When you plot a two dimensional array, you ordinarily get a bunch of lines, colored like this. Specify Color of a Bar Chart Create a red bar chart by calling the bar function and specifying the optional color argument as " red". But the problem is it only adds one legend on one plot. This is a 2-element numeric array specifying the minimal size of the legend entries’ icon and label. % This file plots gamma as a function of v/c as well as some of its Taylor. You also can create a legend with multiple columns or create a legend for a subset of the plotted data. Here are the colors, in order, and their MATLAB RGB triplet. The default colors provide a clean and consistent look across the different plots you create. As we have already stated here, by writing help plot or doc plot in Matlab you will be able to find the information we are about to give you down below. h2 = plot (dataset2,'color','r') legend ( [h1 (1), h2 (1)], 'DATASET1', ' DATASET2') This is telling legend that you want one entry for the first item from the first call to plot (i. As such, your legend command is applying the legend to the first three plot s, all from the first call to. The basic syntax is: legend ( 'Description 1', 'Description 2', … ). You need to get the handles from whatever you want to be in the legend, like the returned value of plot() or patch() or whatever. To control the appearance of legend entries, plot points that have values which are NaN then pass the objects returned by plot and an array of labels to the legend function (NaN points are not visible in the plot, but appear in the legend). Accepted Answer: jonas. When you specify CData (the color input) for scatter, MATLAB uses colormapping to plot the data, and a colorbar to describe the mapping. legend creates a legend with descriptive labels for each plotted data series. I'm running this code and need to make a legend. Likewise, for plotting the graph on MATLAB, we have different colors code or functions. x = linspace (0,10,150); y = cos (5*x); Create a 2-D line plot of the cosine curve. Legend Properties Legend appearance and behavior expand all in page Legend properties control the appearance and behavior of a Legend object. You can position a circle with the center specified in axes data space by plotting a single point using a circle marker. The simplest way to use the function is to pass in a character string for each line on. MATLAB ® creates plots using a default set of colors. How to Implement Matlab Plot Colors with Examples. Here are the colors, in order, and their MATLAB RGB triplet. Plot legend and labels. ItemTokenSize == [10, 1]; % shrink legend icons and labels. Specify Plot Colors MATLAB ® creates plots using a default set of colors. I am trying to annotate a bubblechart (R2022b) that is on a semilogy scale. For labels, it uses one of the properties of data series which is known as DisplayName. Use plot handles as input to the legend function, and you won't have this problem. Here are the different type of plots in Matlab. Plot legend customization ; 1, hLegend. Use dot notation to refer to a particular. legend creates a legend with descriptive labels for each plotted data series. The default colors provide a clean and consistent look across the different plots you create. Use the linspace function to define x as a vector of 150 values between 0 and 10. Setting: The setting is when and where the story takes place. You can see there are multiple entries and I suspect that is because the variables returned by the voronoi function are matrices and not vectors like the other variables. You can also use a specified line style, marker, and colorfor drawing 3D plots. It includes the setting, characters, conflict, action and resolution of the story. As described in this SO post, it can look nice when the text in the legend is the same color as the line or marker. com/_ylt=AwrEppDMWWNjhyMKCjRXNyoA;_ylu=Y29sbwNiZjEEcG9zAzIEdnRpZAMEc2VjA3Ny/RV=2/RE=1667484237/RO=10/RU=https%3a%2f%2fwww. h (1)=plot (x,y,'LineWidth',lw); h (2)=plot (x,y,'LineWidth',lw); legend (h,'gamma','T0',);. By default, the plot() function draws a line from point to point. If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca. Plot markers transparency and color gradient. How to change color of lines on legend?. Now I want to change the color of second line of legend to red without changing anything in data. Tutorial - Introducing multiple legends in Matlab figure/ plotIn this short video tutorial, simple method to introduce multiple legends in Matlab figure is s.