简体   繁体   English

获取八度中 plot 标记和行 styles 的列表

[英]Obtain lists of plot marker and line styles in Octave

Is there a way to programmatically obtain the list of marker and line styles available for plotting in Octave?有没有办法以编程方式获取标记列表和行 styles 可用于在 Octave 中绘图?

Ideally, I would do something like理想情况下,我会做类似的事情

mslist = whatever_function_for_marker_styles;
lslist = whatever_function_for_line_styles;
for i = 1:np
    plot(x, y(i,:), 'marker', mslist(i), 'linestyle', lslist(i))
endfor

Notes:笔记:

  1. I would add some mod functions to cycle across the lists.我会添加一些mod函数来循环遍历列表。
  2. I know the size of both lists may not be the same, so they may shift from one another upon cycling.我知道两个列表的大小可能不一样,因此它们可能会在骑车时相互转移。

The easiest way would be to get the symbols from the manual and put them in a cell array:最简单的方法是从手册中获取符号并将它们放入单元格数组中:

mslist = {'+', 'o', '*', '.', 'x', 's', 'd', '^', 'v', '>', '<', 'p', 'h'};

lslist = {'-', '--', ':', '-.'};

You can loop over them with a standard for-loop and access them by index using curly brackets, eg lslist{i}.您可以使用标准 for 循环遍历它们,并使用大括号通过索引访问它们,例如 lslist{i}。 The symbols are in Section 15.2.1 of the manual ( https://octave.org/doc/v6.1.0/Two_002dDimensional-Plots.html#Two_002dDimensional-Plots ).这些符号位于手册的第 15.2.1 节( https://octave.org/doc/v6.1.0/Two_002dDimensional-Plots.html#Two_002dDimensional-Plots )。 An ordinary vector would work for mslist instead of a cell array as all the symbols are single characters, but not for lslist where some of them are two characters long.普通向量适用于 mslist 而不是元胞数组,因为所有符号都是单个字符,但不适用于其中一些是两个字符长的 lslist。

I agree with Howard that doing it 'entirely' programmatically is probably overkill.我同意霍华德的观点,即“完全”以编程方式进行可能是矫枉过正。

However, if you do want to do that, my bet would be to parse the 'help' output for the 'plot' command, which is guaranteed to mention these points, and has a reasonable guarantee that it will remain in the same format even if more markers are added in the future etc.但是,如果您确实想这样做,我的赌注是解析“绘图”命令的“帮助”output,它保证会提到这些点,并且有合理的保证即使它保持相同的格式如果将来添加更多标记等。

I won't parse the whole thing, but if you were to do this, you'd probably start like this:我不会解析整个事情,但如果你这样做,你可能会这样开始:

plotdoc = help('plot');                                                                                                                                                                                                                                                                                                       
[plotdoc_head   , plotdoc_rest] = deal( strsplit( plotdoc     , '     linestyle' ){:} );                                                                                                                                                                                                                                      
[plotdoc_lines  , plotdoc_rest] = deal( strsplit( plotdoc_rest, '     marker'    ){:} );                                                                                                                                                                                                                                      
[plotdoc_markers, plotdoc_rest] = deal( strsplit( plotdoc_rest, '     color'     ){:} );                                                                                                                                                                                                                                      
[plotdoc_colors , plotdoc_rest] = deal( strsplit( plotdoc_rest, '";displayname;"' ){:} );                                                                                                                                                                                                                                     

or something along those lines, and then use regexp or strfind / strtoken / strplit creatively to obtain the necessary tokens in each category.或类似的东西,然后创造性地使用 regexp 或 strfind / strtoken / strplit 来获得每个类别中必要的令牌。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM