Matlab 绘图的自定义标记

Custom Markers for Matlab plot

我搜索了google,每个人都说不支持。我想知道是否有任何开放社区 matlab 函数能够将用户定义的 png 绘制为标记。我找到的最接近的是 http://de.mathworks.com/matlabcentral/fileexchange/39487-custom-marker-plot/content/plotCustMark/plotCustMark.m。但它并没有达到预期的目的。 让我知道我是否有可能为此写点什么!谢谢

其他问题:好的,我现在遇到了这个奇怪的问题。我的 png 背景是黑色的!!我不明白为什么。我试过降低alpha值还是不行。

解决方案 : 我在@brainkz 评论中提到的问题可以通过

解决

http://de.mathworks.com/matlabcentral/answers/144411-displaying-image-over-background-making-top-image-background-color-transparent

方法:通过

导入图片的透明度设置
[marker,map,transperancy ] = imread('car.png');

以后设置

handleIm = imagesc([x_low x_high], [y_low y_high], marker)
set(handleIm ,'AlphaData',transperancy);

澄清:图像都是透明的,但由于我将其覆盖在另一幅图像上,它会将当前图像背景变为默认黑色。我发布了这个问题的解决方案,我想这对很多人来说真的很有用。

imagesc 可以把 png 放到你的图上。我们可以通过以下方式利用这一点:

定义用户数据:

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

加载标记图像:

marker = imread('icon.png');

定义标记大小并调整 xy 数据:

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

然后,我们将加载的图像放在指定点的绘图上

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

最后,您很可能会得到以下信息:

要获得理想的外观,您需要调整一下参数。

希望对您有所帮助