フィルターのクリア

help with plotting needed!

1 回表示 (過去 30 日間)
YH
YH 2020 年 1 月 19 日
コメント済み: darova 2020 年 1 月 19 日
Hey guys,
I have 4 vectors HQ10, HQ100,HQ1000,HQ10000
for example: HQ10 =[1 1.5 1.7 1.6 1.8 2.1 2.2 2.5]
HQ100 = [1.9 2 2.2 2.5 2.7 2.9 3 3.1]
I want to plot them like in the figure attached where the x axes (HQ10 HQ100 HQ1000 HQ10000), and y axes represents the values.
I want the first value of all the vectors be the same colour, the second values be the same colour, and so on..
I hope I made my question clear because it is a little bit difficult to explain
would welcome any help or suggestions
thanks in advanced!

採用された回答

darova
darova 2020 年 1 月 19 日
Use plot
clc,clear
HQ10 = [1 1.5 1.7 1.6 1.8 2.1 2.2 2.5];
HQ100 = [1.9 2 2.2 2.5 2.7 2.9 3 3.1];
HQ1000 = rand(1,length(HQ10))*3;
cmap = jet(8); % color data
x1 = [-1 1]*0.1; % line length
hold on
for i = 1:length(HQ10)
h(1) = plot(x1+1,HQ10(i)+x1*0);
h(2) = plot(x1+2,HQ100(i)+x1*0);
h(3) = plot(x1+3,HQ1000(i)+x1*0);
set(h,'color',cmap(i,:))
set(h,'linewidth',3)
end
hold off
  2 件のコメント
YH
YH 2020 年 1 月 19 日
Thank you very much! that what I was looking for.
Do you know how I can ledgend by the colour?
for example the blue line represents 1900 , light bule represent 1800, green represents 1700
darova
darova 2020 年 1 月 19 日
h = zeros(length(HQ10),3);
hold on
for i = 1:length(HQ10)
h(i,1) = plot(x1+1,HQ10(i)+x1*0);
h(i,2) = plot(x1+2,HQ100(i)+x1*0);
h(i,3) = plot(x1+3,HQ1000(i)+x1*0);
set(h(i,:),'color',cmap(i,:))
end
set(h,'linewidth',3)
legend(h(:,1),'blue', ...
'blue1', ...
'cyan', ...
'green', ...
'yellow')
hold off

サインインしてコメントする。

その他の回答 (1 件)

tomer polsky
tomer polsky 2020 年 1 月 19 日
do you mean like this ?
HQ10 =[1 1.5 1.7 1.6 1.8 2.1 2.2 2.5]
HQ100 = [1.9 2 2.2 2.5 2.7 2.9 3 3.1]
plot(HQ10,'red');
hold on;
plot(HQ100 ,'blue');
legend('HQ10','HQ100')
  1 件のコメント
YH
YH 2020 年 1 月 19 日
編集済み: YH 2020 年 1 月 19 日
no, I mean in the same way as in the image I have attached.
every first value of the vectores represents a time period. this is way I want to plot the first values at the same coluor, then the second values at another colour..
I dont really know what type of plotting that is. tried to search the answers here but couldnt see some thing similar.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by