用于Matlab绘图的自定义标记

Say*_*Roy 5 matlab plot markers

我搜索了谷歌,每个人都说它不受支持.我想知道是否有任何开放的社区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');
Run Code Online (Sandbox Code Playgroud)

然后设定

handleIm = imagesc([x_low x_high], [y_low y_high], marker)
set(handleIm ,'AlphaData',transperancy);
Run Code Online (Sandbox Code Playgroud)

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

bra*_*nkz 9

imagesc可以把png放在你的情节上.我们可以通过以下方式利用这一点:

定义用户数据:

x = 1:10;
y = 5*rand(size(x)) + 2.5;
Run Code Online (Sandbox Code Playgroud)

加载标记图像:

marker = imread('icon.png');
Run Code Online (Sandbox Code Playgroud)

定义标记大小并调整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
Run Code Online (Sandbox Code Playgroud)

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

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
Run Code Online (Sandbox Code Playgroud)

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

在此输入图像描述

要获得所需的外观,您需要暂时使用参数.

希望有所帮助

  • @brainkz考虑添加解决方案,他建议,给你答案!很可能有人会举报,因为问题不是回答问题的地方! (2认同)