Plot Multiple Time Series Based on Individual Condition

6 ビュー (過去 30 日間)
Dima
Dima 2011 年 9 月 14 日
Hello Friends!
I am somewhat new to scientific charting) more accustomed to working in Excel, but I think I have run into its limitation as regards to charting…I am not sure if Matlab can do the following…
1) Take the time series data from excel, each data series will have three describers (first three rows of each column) – COLOUR, TYPE and THICKNESS 2) plots each time series data in such a way as: a) colors the time series according to a time series criterion (eg. 1 for red, 2 for black) b) allows to adjust the thinness of the plotted series based on another criterion (e.g. 10 very thick, 2- close to hairline) c)Sets the type of the trendline to dashed/solid (based on the Type criterion)
I can send an example worksheet if necessary..
Thanks for your time!) I will be glad to hear any opinion.
Dima

採用された回答

Walter Roberson
Walter Roberson 2011 年 9 月 14 日
You may wish to create some cell arrays to help:
colors = {'r', 'k', 'g'}; %red, black, green
linetypes = {'--', '-'}; %dashed, solid
% ....
thislinespec = [colors{column1}, linetypes{column2}];
thisthick = column3;
plot(x, y, thislinespec, 'thickness', thisthick);
  12 件のコメント
Walter Roberson
Walter Roberson 2011 年 9 月 15 日
Fangjun, 'thickness' refers to the thickness of my head when I'm working on too many things at one time ;-(
Dima
Dima 2011 年 9 月 15 日
yeah))) thickness must refer to the linewidth)))) Walter hopefully)) your head linewidth will go back to normal)))) Maybe then you can still help me create this kind of code that can build upon later...thanks!

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

その他の回答 (2 件)

Fangjun Jiang
Fangjun Jiang 2011 年 9 月 14 日
Yes, all is pretty straightforward in MATLAB. You can type help plot or doc plot in MATLAB for more information. Try this example for yourself.
figure;hold on
plot(1:10,'r','linewidth',10)
plot(rand(10,1),'g--')
Code below applies to a simple example Excel file.
[Num,Txt,Raw]=xlsread('test.xls');
colors = {'r', 'k', 'g'}; %red, black, green
linetypes = {'--', '-'}; %dashed, solid
figure(1);hold on;
for k=2:4
plot(Num(4:end,1),Num(4:end,k),[colors{Num(1,k)},linetypes{Num(2,k)}],'linewidth',Num(3,k));
end
  25 件のコメント
Fangjun Jiang
Fangjun Jiang 2011 年 9 月 17 日
The function is text().
Dima
Dima 2011 年 9 月 18 日
thanks....it is inserted in the list of the arguments of the plot function right?

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


Dima
Dima 2011 年 9 月 28 日
Fangjun Jiang! Maybe you can also help me with one more questions about the code you provided before....I wonder if it is possibel to specify the colors not in the default format (e.g. 'r') but in the RGB format ( [1 0 0])? I ask this because I need different shades few red and blue...) Thanks!) D
  1 件のコメント
Walter Roberson
Walter Roberson 2011 年 9 月 28 日
[Num,Txt,Raw]=xlsread('test.xls');
colors = {'r', 'k', [0.6 0.8 3.9]}; %red, black, green
linetypes = {'--', '-'}; %dashed, solid
figure(1);hold on;
for k=2:4
plot(Num(4:end,1),Num(4:end,k),linetypes{Num(2,k)},'linewidth',Num(3,k), 'color', colors{k} );
end

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

カテゴリ

Help Center および File ExchangeMATLAB Functions in Microsoft Excel についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by