A basic plotting problem in a for loop
1 次查看(过去 30 天)
显示 更早的评论
Hello everybody,
I have a Problem which seems to be very stupid and I apologize for my question in advance!
I have a for loop to plot all of the results of a former loop. Now I would like to change the color of the plots to grey. Basically this is not a big deal if you have x and y for example. In my case I plot data1 vs data2. Both of them have the same size. If I use a colormap or something like 'color', [1 1 1] I always get the error that the vectors must be the same size. How can I fix this?!
for d=1:numel(Filename)
figure(1);
hold on
plot(Data_1(:,d), Data_2(:,d), 'Color', [1 1 1])
axis([-25 25 -20 25])
axis equal
end
Thank you!
Cheers
Christian
3 个评论
Stephen23
2017-2-2
@Christian: please edit your question and give us the complete error message. This means all of the red text.
采纳的回答
tafteh
2017-2-2
Hi Christian,
(b) Unless the vectors Data_1(:,d) and Data_2(:,d) are not the same size, you should not get an error.
(c) using the argument 'Color' with the value of [1 1 1], results in plotting all the lines in white which is the same as the white background of plotting environment. You may want to change that :)
(d) I wrote the following code trying to mimic what you want to do:
first I generate two 2d matrices, a and b with same size:
if true
a = rand(3, 4); b = rand(3, 4);
end
and then I use your code to plot them:
if true
for d=1:size(a, 2) % mimic the numel(Filename) in your code.
figure(1);
hold on
plot(a(:,d), b(:,d), 'Color', [.1 .1 .1])
axis([-25 25 -20 25])
axis equal
end
end
it works for me. You may want to change the code based on your need.
cheers,
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Distribution Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!