Change color of 2D plot line depending on 3rd value

前端 未结 5 1979
Happy的楠姐
Happy的楠姐 2020-11-30 10:40

I have a data set that looks like this

 140400 70.7850 1
 140401 70.7923 2
 140402 70.7993 3
 140403 70.8067 4
 140404 70.8139 5
 140405 70.8212 3

5条回答
  •  暖寄归人
    2020-11-30 11:05

    When the result figure of two variables plotted is a circle, will be necessary to add the time in z axes.

    For example the figure of induction machine rotor velocity vs electric torque in one laboratory test is: 2d plot figure

    In the last figure the direction of the time point plotting could be clockwise or counter clockwise. For the last reason will be added time in z axis.

    % Wr vs Te
    x =  logsout.getElement( 'Wr' ).Values.Data; 
    y =  logsout.getElement( '' ).Values.Data;
    z =  logsout.getElement( '' ).Values.Time;
    % % adapt variables for use surf function
    xx = zeros( length( x ) ,2 );
    yy = zeros( length( y ) ,2 );
    zz = zeros( length( z ) ,2 );
    xx (:,1) = x; xx (:,2) = x;
    yy (:,1) = y; yy (:,2) = y;
    zz (:,1) = z; zz (:,2) = z;
    % % figure(1) 2D plot
    figure (1)
    hs = surf(xx,yy,zz,yy,'EdgeColor','interp') %// color binded to "y" values
    colormap('hsv')
    view(2) 
    % %
    figure(2)
    hs = surf(xx,yy,zz,yy,'EdgeColor','interp') %// color binded to "y" values
    colormap('hsv')
    view(3) 
    

    Finally we can view the 3d form and detect that counterwise is the real direction of the time plotting is: 3d plot

提交回复
热议问题