Hi everyone,
I am a newbee of Matlab. I am having some issues with plotting. I could use some help.
When I try to plot multiple sets of data, the axies get mudy. I assue it's caused by the overlapping of different scales. Is there a way to clean it up?
T1=[50 53 55 58 59 60 61 61 62]
T2=[ 48 50 52 54 55 57 58 59 60 61 62 62 63]
dCoF1=[2.088360144 2.348487525 2.48784046 2.67016458 2.795948305 2.84171836 2.619815575 2.663693217 2.6249562]
dCoF2=[3.370696371 2.075218238 2.272783201 2.440811388 2.444426417 2.614530643 2.585023679 2.531044092 2.666287724 2.59727857 2.603275966 3.366966847 2.685168655]
p=plot (T1,dCoF1,"-k",T2,dCoF2,"-c")
p(1).Marker="*"
p(2).Marker="o"
Another issue is that I have a set of data that describe force reading under different temperatures. Naturally I want to visualize the data points. Making the data coordinates fall into "temperature bins". Currently I am using line plot, but I am sure there is a better way to do it.
My Data set:
[(Temperature, Reading)] = [(55,1.98);(58,1.88);(61,2.00);(55,1.93);(56,1.74);(56,1.88)]
I am thinking asking Matlab to plot based on coordinates, but I don't know how to use a matrix to store the coordinates, and use the plot function.Can you give me any insight?

댓글 수: 2

I get a much ‘cleaner’ result that what you posted.
What MATLAB release are you using?
Have you updated it with the latest Update?
Hi Star Strider,
I am using '9.9.0.1592791 (R2020b) Update 5'.
This issue happened after I plot some data using "hold on".
Actually today I ran this section and the issue is gone. Maybe I should share this piece:
ax = axes;
ax.ColorOrder = [1 1 0;1 0 1; 0 1 1; 1 0 0; 0 1 0; 0 0 1; 1 1 1; 0 0 0]
hold on
for i = 1:22
plot([1:48285],result(:,i))
end
hold off
Please let me know.

댓글을 달려면 로그인하십시오.

 채택된 답변

Star Strider
Star Strider 2021년 3월 31일

0 개 추천

I am thinking asking Matlab to plot based on coordinates, but I don't know how to use a matrix to store the coordinates, and use the plot function.Can you give me any insight?
If they all have the same length (with respect to the independent variable, as they appear to do in this Comment), try something like this:
x = 1:20;
y = rand(5,20)+(0:4).';
figure
plot(x, y)
ax = gca;
ax.ColorOrder = [1 1 0;1 0 1; 0 1 1; 1 0 0; 0 1 0; 0 0 1; 1 1 1; 0 0 0];
.

댓글 수: 4

Hi Star strider,
Thanks for the update. Can you give me a little explaination on the code?
x = 1:20;
y = rand(5,20)+(0:4).'; %rand (5,20) means generate a 5X20 matrix. What does (0:4).'mean? a column arrary [0 1 2 3 4] added to the random array? what does the "." mean?
figure % why this, can we take it away?
plot(x, y)
ax = gca; % does it need to be declared before a loop or during the loop?
ax.ColorOrder = [1 1 0;1 0 1; 0 1 1; 1 0 0; 0 1 0; 0 0 1; 1 1 1; 0 0 0];% does it need to be declared before a loop or during the loop?
Sure!
I created the ‘x’ vector and the matrix of ‘y’ values to demonstrate the approach. The ‘y’ matrix is simply a random aarray with added offsets created by the ‘(0:4).'’ column vector, so that the lines are vertically separated. I copied the color order matrix from your original code to demonstrate how to apply it in this instance.
The plot function figures out how to plot the matrix as a function of the ‘x’ vector. The only time it is necessary to transpose the ‘y’ matrix is if it is square, and you want to plot across the columns of the original instead of the rows.
Thanks a lot, my friend!
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Graphics Performance에 대해 자세히 알아보기

제품

질문:

2021년 3월 31일

댓글:

2021년 4월 1일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by