matlab plot point,plot_point.m

%PLOT_POINT Draw a point

%

% PLOT_POINT(P, OPTIONS) adds point markers and optional annotation text

% to the current plot, where P (2xN) and each column is a point coordinate.

%

% H = PLOT_POINT(...) as above but return handles to the points.

%

% Options::

% 'textcolor', colspec Specify color of text

% 'textsize', size Specify size of text

% 'bold' Text in bold font.

% 'printf', {fmt, data} Label points according to printf format

% string and corresponding element of data

% 'sequence' Label points sequentially

% 'label',L Label for point

%

% Additional options to PLOT can be used:

% - standard MATLAB LineStyle such as 'r' or 'b---'

% - any MATLAB LineProperty options can be given such as 'LineWidth', 2.

%

% Notes::

% - The point(s) and annotations are added to the current plot.

% - Points can be drawn in 3D axes but will always lie in the

% xy-plane.

% - Handles are to the points but not the annotations.

%

% Examples::

% Simple point plot with two markers

% P = rand(2,4);

% plot_point(P);

%

% Plot points with markers

% plot_point(P, '*');

%

% Plot points with solid blue circular markers

% plot_point(P, 'bo', 'MarkerFaceColor', 'b');

%

% Plot points with square markers and labelled 1 to 4

% plot_point(P, 'sequence', 's');

%

% Plot points with circles and labelled P1, P2, P4 and P8

% data = [1 2 4 8];

% plot_point(P, 'printf', {' P%d', data}, 'o');

%

%

% See also PLOT_SPHERE, PLOT, TEXT.

% Copyright (C) 1993-2019 Peter I. Corke

%

% This file is part of The Spatial Math Toolbox for MATLAB (SMTB).

%

% Permission is hereby granted, free of charge, to any person obtaining a copy

% of this software and associated documentation files (the "Software"), to deal

% in the Software without restriction, including without limitation the rights

% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies

% of the Software, and to permit persons to whom the Software is furnished to do

% so, subject to the following conditions:

%

% The above copyright notice and this permission notice shall be included in all

% copies or substantial portions of the Software.

%

% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS

% FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR

% COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER

% IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN

% CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

%

% https://github.com/petercorke/spatial-math

function ho = plot_point(p, varargin)

opt.textcolor = 'k';

opt.textsize = 12;

opt.printf = [];

opt.sequence = false;

opt.bold = false;

opt.label = [];

opt.solid = false;

[opt,arglist,ls] = tb_optparse(opt, varargin);

% label is a cell array, one per point (column)

if ~isempty(opt.label) && numcols(p) == 1

% if single point, convert single label to a cell array

opt.label = {opt.label};

end

% default marker style

if isempty(ls)

ls = {'bs'}; % blue square

end

% add stuff to pull .u and .v out of a vector of objects

if ~isnumeric(p) && any(strcmp('u_', properties(p)))

% p is an object with u_ and v_ properties

p = [[p.u_]; [p.v_]];

end

if numrows(p) == 3

error('p must have 2 rows, only supports 2D plotting')

end

holdon = ishold();

hold on

h = zeros(1,numcols(p));

for i=1:numcols(p)

if opt.solid

arglist = [ 'MarkerFaceColor', ls{1}(1), arglist];

end

h(i) = plot(p(1,i), p(2,i), ls{:}, arglist{:});

if opt.sequence

show(p(:,i), '%d', i, opt);

end

if ~isempty(opt.label)

show(p(:,i), opt.label{i}, [], opt);

elseif ~isempty(opt.printf)

show(p(:,i), opt.printf{1}, opt.printf{2}(i), opt);

end

end

if ~holdon

hold off

end

figure(gcf)

if nargout > 0

ho = h;

end

end

function show(p, fmt, val, opt)

if opt.bold

fw = 'bold';

else

fw = 'normal';

end

text(p(1), p(2), sprintf([' ' fmt], val), ...

'HorizontalAlignment', 'left', ...

'VerticalAlignment', 'middle', ...

'FontUnits', 'pixels', ...

'FontSize', opt.textsize, ...

'FontWeight', fw, ...

'Color', opt.textcolor);

end

一键复制

编辑

Web IDE

原始数据

按行查看

历史

1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值