Custom Markers for Matlab plot

房东的猫 提交于 2019-11-27 14:31:59

imagesc can put the png on you plot. We can avail ourselves of this in the following way:

Define user data:

x = 1:10;
y = 5*rand(size(x)) + 2.5;

Load the marker image:

marker = imread('icon.png');

Define marker size and adjust the x and y data:

markersize = [1,1]; %//The size of marker is expressed in axis units, NOT in pixels
x_low = x - markersize(1)/2; %//Left edge of marker
x_high = x + markersize(1)/2;%//Right edge of marker
y_low = y - markersize(2)/2; %//Bottom edge of marker
y_high = y + markersize(2)/2;%//Top edge of marker

Then, we put our loaded image on the plot at the specified points

for k = 1:length(x)
    imagesc([x_low(k) x_high(k)], [y_low(k) y_high(k)], marker)
    hold on
end
axis equal
hold off

At the end, you are likely to get the following:

To achieve the desired appearance, you would need to play with the parameters for a while.

Hope that helps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!