【发布时间】:2019-07-23 12:57:06
【问题描述】:
根据documentation for plot(),我应该可以传递一个格式参数来控制图形的样式。但是,Octave 似乎将其误解为不完整的属性规范,而不是格式字符串:
$ octave-cli
GNU Octave, version 4.4.1
Copyright (C) 2018 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. For details, type 'warranty'.
Octave was configured for "x86_64-pc-linux-gnu".
Additional information about Octave is available at https://www.octave.org.
Please contribute if you find this software useful.
For more information, visit https://www.octave.org/get-involved.html
Read https://www.octave.org/bugs.html to learn how to submit bug reports.
For information about changes from previous versions, type 'news'.
1> t = linspace(0,5,1001);
2> plot(t, sin(pi*t), "g_;sin(πt)");
error: plot: properties must appear followed by a value
error: called from
__plt__ at line 90 column 15
plot at line 223 column 10
是我做错了什么还是这是一个错误?
【问题讨论】:
-
这显然不是一个有效的格式规范。你想用那里的
sin(πt)做什么? -
@TasosPapastylianou 这是一个“显示名称”,是用于情节图例的标签。为什么说无效?此外,即使您只使用“g_”作为绿色实线,也会出现相同的错误。
-
好的,我不知道这个特殊的图例语法,因为我倾向于单独设置它,但是,无论如何,请完全按照规范进行,您会发现错字。具体来说,它是一个破折号而不是下划线,如果您使用标签,您似乎需要在标签名称之前和之后使用分号,即
plot(t, sin(pi*t), "g-;sin(πt);"); -
@TasosPapastylianou 感谢您的鹰眼!不知何故,我错过了那些东西。如果您想将您的评论变成官方答案,我会接受。否则,我会自我接受,所以它看起来仍然没有答案。
标签: octave