Plotting Matrix Data Points with a Specific Color
조회 수: 4 (최근 30일)
이전 댓글 표시
Just wondering if there's a way to graph the data points listed in bal_1 in different colors so as to differentiate one row from another. The current code generates an image like the one you see below, and I'd just like to add different colors so I can distinguish one row from another. For instance, one row to be blue, the next to be red, etc.
bal_1 = [0.9445 0.9274 0.9379 0.8823;
0.9407 0.9348 0.9325 0.9313;
0.9185 0.9296 0.9195 0.9391;
0.9462 0.9294 0.9409 0.9426];
bal_t1 = transpose(bal_1); %transpose of all data for anova1 testing
balloons_1 = {'#2' '#3' '#5' '#9'};
x{1} = 1:size(bal_t1,2);
figure(2)
plot(x{1}, bal_t1, '+b') % Plot Matrix
axis([0 5 0.875 1]) % Set Axis Limits
set(gca, 'XTick',x{1}, 'XTickLabel',{'#2' '#3' '#5' '#9'}) % Set Tick Labels
xlabel('Balloon Number','FontSize',10,'FontWeight','bold')
ylabel('Pressure Change Rate (kPa/min)','FontSize',12,'FontWeight','bold')
댓글 수: 0
답변 (1개)
Debarati Banerjee
2016년 6월 23일
Just changing the plot command a bit may work for you:
plot(x{1}, bal_t1(:,1), '+b',x{1}, bal_t1(:,2), '+r',x{1}, bal_t1(:,3), '+g',x{1}, bal_t1(:,4), '+m')
Cheers
Debarati
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Colormaps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!