How to get this kind of plot

2 ビュー (過去 30 日間)
Edward
Edward 2013 年 11 月 16 日
コメント済み: Edward 2013 年 11 月 18 日
I have 3d discrete dataset where for every independent variable x and y there is a frequency value z.
I want to plot it like the chart below:
How do i do this?
Thanks
  2 件のコメント
per isakson
per isakson 2013 年 11 月 16 日
Hint:
imagesc( magic(12) )
Edward
Edward 2013 年 11 月 16 日
Thankyou! is there anyway i can change the 0 color to something other than blue?

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

採用された回答

per isakson
per isakson 2013 年 11 月 16 日
編集済み: per isakson 2013 年 11 月 17 日
It requires a bit of code to make this plot.
  • select a suitable colormap (You might have to define your own. See colormapeditor.) Let ix=1 be white.
  • map the frequences to the colormap-indicies, e.g [1:64] (should have been [2:64]). Assign 1 to missing values or whatever white means.
  • use image - not imagesc
  • fix the axes ticklabels
or better(?)
  • select the colormap of your choice and add an extra row for the "missing-value-color"
  • map frequency to the "colormap" and missing-value to the "extra row".
  • the colorbar ticklabels will require some extra work
I use the approach described above. Pro: I get full control of the colors and the resulting code is fast. Con: requires some coding and testing.
pcolor might offer a simpler way. Try
x = [1:8];
y = [1:8];
z = x' * y ;
z(4:5,7) = nan;
pcolor( x, y, z )
Note, this gives a plot with 7x7 squares.
  2 件のコメント
per isakson
per isakson 2013 年 11 月 17 日
I updated the answer
Edward
Edward 2013 年 11 月 18 日
Thanks for the help, Ive accepted your answer!

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by