Assign colour to grid cells of arbitrary length given the index of the cell

2 次查看(过去 30 天)
Hi i am trying to recreate the following image, in this image each grid is a 2x2 square and the color represents the probability of occupancy.
I have the index of the cell corner example matrix c = [1 1; 2 3; 4 5] and values corresponding to those cells logprob = [0.5, 0.3, 0.8]
I have tried using imagesc still i am not able to apply it to achieve the desired result, since it doesn't have a cell width property. any help is greatly appreciated thank you.
  1 个评论
Walter Roberson
Walter Roberson 2020-9-4
You can pass XData and YData properties to imagesc() in order to control the positions of the data pixels in data coordinates. By careful choice of axes Position and axes Units properties, and using the XData and YData properties, you can control the exact number of pixels that an image will take on the display.
However:
  1. Be careful: XData and YData correspond to coordinates of the centers of the boundary pixels, not to the edges. You need to allow space for half a pixel relative to the coordinates given
  2. With high enough resolution displays, on Windows MATLAB maps 100 "pixels" to 1 inch, and on Mac MATLAB maps 72 "pixels" to 1 inch. Determining the correct adjustment for physical pixels can be a nuisance.
  3. data pixels cannot be different sizes when this is used. If you need data pixels to be different sizes, see warp()
... But I suspect that is not what you are talking about. I suspect what you are looking for is painting the grid. "grid on", and look at XTicks and XMinorTicks to control grid locations.

请先登录,再进行评论。

回答(0 个)

类别

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

产品

Community Treasure Hunt

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

Start Hunting!

Translated by