refaiwant.blogg.se

Changing plot color matlab
Changing plot color matlab








changing plot color matlab

X = logsout.getElement( 'Wr' ).Values.Data For the last reason will be added time in z axis. In the last figure the direction of the time point plotting could be clockwise or counter clockwise. When the result figure of two variables plotted is a circle, will be necessary to add the time in z axes.įor example the figure of induction machine rotor velocity vs electric torque in one laboratory test is: 2d plot figure Plot(x,y,'Color',color,'LineWidth',lineWidth1) % segment from P1 to P2 have the color that corresponds with P1 % Create X and Y that will go into plot, This will make the line For 10 plots, you obviously cannot rely on the default ColorOrder, so a great way to define N visually distinct colors is with the 'Generate Maximally Perceptually-Distinct Colors' (GMPDC) submission on the MATLAB Central File File Exchange. % Get color that corresponds to that value % Store locations of the value we are looking to plot % Loop through the locations of the values and plot their data points My desired effect was achieved below (simplified): indices(1).index = find( data( 1 : end - 1, 3) = 1) Will give you a sine wave with the color associated to the y value:

changing plot color matlab

Hs=surf(xx,yy,zz,yy,'EdgeColor','interp') %// color binded to "y" values View(2) %// view(0,90) %// set view in X-Y planeĪs an example of a more general case: x=linspace(0,2*pi) Shading flat %// so each line segment has a plain color Hs=surf(xx,yy,zz,cc,'EdgeColor','interp','FaceColor','none','Marker','o') Ĭolormap(custom_colormap) %// assign the colormap Zz=zeros(size(xx)) %// everything in the Z=0 plane Xx= %// create a 2D matrix based on "X" column %% // your dataĬ = M(:,3) %// extract color index for the custom colormap Matlab surf does not handle 1D data, it needs a matrix as input so we are going to give it by just duplicating each coordinate set (for example xx=).ĭon't worry though, the surface will stay as thin as a line, so the end result is not ugly. Surfaces benefit from their CData properties and a lot of useful features to exploit color maps and texture. The trick is to use a surface instead of a line object.

changing plot color matlab

However, is will never be as simple as you expected (unless you write a wrapper for one of the solution here you can forget about plot(x,y,)). You can also do it with a trick which works with Matlab version anterior to 2014b (as far back as 2009a at least).










Changing plot color matlab