Matlab: Changing line specifications

自古美人都是妖i 提交于 2019-12-06 08:14:49

I think you may be overcomplicating it?

Try something like this:

% MarkerSize determines the size of the markers
% MarkerEdgeColor determines the color of the markers themselves
% Color determines the line color connecting them
data = rand(1,5);
plot(data, '.--', 'MarkerSize', 50, 'MarkerEdgeColor', [0.1 0.8 0.2], 'Color', [0.9 0.2 .4]);

It produces the following image of opaque markers connected with dashed lines:

To support plotyy, the process is basically the same, except you have to set some properties on both the parent and child axes. Here's some example code:

% Generate some data
datax1 = rand(1,5);
datay1 = rand(1,5);
datax2 = rand(1,5);
datay2 = rand(1,5);

% Plot the data    
[ax, h1, h2] = plotyy(datax1, datay1, datax2, datay2);

% Different line styles for each child plot
set(h1, 'LineStyle', '--');
set(h2, 'LineStyle', '-.');

% Different markers for each child plot
set(h1, 'Marker', '.');
set(h2, 'Marker', '+');

% Different marker sizes for each child plot
set(h1, 'MarkerSize', 50);
set(h2, 'MarkerSize', 5);

% Generate two colors. We keep a copy so we can set the axes to match.
color1 = rand(1,3);
color2 = rand(1,3);

% The face colors are darker versions of the colors.
set(h1, 'MarkerEdgeColor', color1 * 0.5);
set(h2, 'MarkerEdgeColor', color2 * 0.5);

% This is the plot line color.
set(h1, 'Color', color1);
set(h2, 'Color', color2);

% Set the axis colors to match the plot colors.
set(ax(1), 'YColor', color1);
set(ax(2), 'YColor', color2);

Which produces the following image:

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