Plot a table into 16 rectangles

3 次查看(过去 30 天)
Kent Mey
Kent Mey 2014-2-10
回答: Kent,et 2014-2-10
Hi,
I am trying to plot this table (below) as 16 rectangles of equal size and each of these rectangles FaceColor being the value within the table
3.046095 ¦ 3.065321 ¦ 2.897449 ¦ 2.766175
2.947777 ¦ 3.005672 ¦ 2.878440 ¦ 2.716963
2.865979 ¦ 2.911387 ¦ 2.780432 ¦ 2.529457
2.797027 ¦ 2.761119 ¦ 2.577187 ¦ 2.360562
I had a look through http://stackoverflow.com/questions/16114573/plotting-a-rectangle-with-colour-representing-a-value-in-matlab, but I couldn't find how to use the faceColor and match it with an actual value.
I look for surf and contourf, but neither of them are suitable since they turn this table into 9 rectangles instead of 16.
  1 个评论
Kent Mey
Kent Mey 2014-2-10
编辑:Kent Mey 2014-2-10
I'll appreciate any help pointing me in the right direction :):):)

请先登录,再进行评论。

回答(3 个)

Iain
Iain 2014-2-10
If you want to do it as a proper 3D plot, you're probably best off by building up patch objects.
e.g.
patch([0 1 1 0],[1 1 0 0],[3.046095 3.046095 3.046095 3.046095],3.046095./max_of_the_table)
If you want just an image. imagesc should do the job. "image" will do it with some thought.

Kent Mey
Kent Mey 2014-2-10
Actually I only want it as a 2D plot, not 3D plot.

Kent,et
Kent,et 2014-2-10
thanks, very useful :)

类别

Help CenterFile Exchange 中查找有关 Polygons 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by