フィルターのクリア

Help with 2D plot from a matrix

2 ビュー (過去 30 日間)
aurc89
aurc89 2020 年 3 月 26 日
回答済み: Adam Danz 2020 年 3 月 30 日
I have a matrix (txt file, named "try")) as the one in the picture (left), with different columns (A to C). This data can be plotted using function plot (picture in the middle).
Since the .txt file is a struct, this is the code I use :
a=importdata('try.txt');
dat=a.data; %This does not take into account the first row of letters
...here I normalized the data to 1 (see graph)
plot(dat)
My question is: is there a way to plot this as from a "top" view? Something similar as in the rigth picture, with point of different color intensity according to the y value (between 0 and 1), and with the label of the first row of letter. Is it possible to do something like that? I hope that the principle is clear.
Thanks for the help!
  2 件のコメント
Adam Danz
Adam Danz 2020 年 3 月 26 日
編集済み: Adam Danz 2020 年 3 月 26 日
In the diagram on the right with circles, what do the row and column indices mean? For example, the 3rd circle in B tells me that there's a peak that's relatively high compared to the other peaks and that it's the 3rd peak, I assume. That's not much information. The transformation from the plot on the left (rich with information) to the plot on the right results in a big loss of information.
If A, B and C vectors all have the same number of rows (or columns) you could put them together in a matrix and use heatmap or imagesc.
aurc89
aurc89 2020 年 3 月 30 日
Thanks Adam!
imagesc is a good results of what I can represent. Is it possible to show the "labels" of the column in the plotted map (A, B and C in the example)?
Other question: is it possible to change the colors of the colorbar (e.g. from white to red instead of blue to red as default) ?

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

回答 (1 件)

Adam Danz
Adam Danz 2020 年 3 月 30 日
Continuing from the comments under the question.
Using imagesc, you can change the tick labels using
set(gca, 'XTick', 1:3, 'XTickLabel', {'A' 'B' 'C'})
and you can change the colormap
colormap('hot')
or any other colormap option.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by