MATLAB:设置要并行应用的线条颜色和样式顺序
当您设置 DefaultAxesColorOrder
和 DefaultAxesLineStyleOrder
时,MATLAB 将首先循环使用第一种样式的所有颜色,然后再次循环使用第二种样式的所有颜色,依此类推。
我想做的是设置独立应用的颜色顺序和样式顺序。
例如,如果我将 DefaultAxesColorOrder
设置为 [1 0 0; 0 1 0; 0 0 1]
和 DefaultAxesLineStyleOrder
为 '-|--|:'
,这些行将是'r-'
,'g-'
,'b-'
,'r--'
,< code>'g--','b--'
,'r:'
,'g:'
,<代码>'b:'。我希望行为 'r-'
、'g--'
、'b:'
。
When you set DefaultAxesColorOrder
and DefaultAxesLineStyleOrder
MATLAB will first cycle through all colors with the first style, then again through all colors with the second style and so on.
See this documentation or related question.
What I would like to do is to set color order and style order to be applied independently.
For example, if I set DefaultAxesColorOrder
to [1 0 0; 0 1 0; 0 0 1]
and DefaultAxesLineStyleOrder
to '-|--|:'
, the lines will be 'r-'
,'g-'
,'b-'
,'r--'
,'g--'
,'b--'
,'r:'
,'g:'
,'b:'
. I want lines to be 'r-'
,'g--'
,'b:'
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我没有找到直接开箱即用的方法。最简单的方法是手动设置每条线的颜色/样式。
这是一个更加自动化的解决方案。让我们从文档中的示例开始:
正如您在问题中所解释的,默认行为是首先循环显示颜色,然后循环显示线条样式。如果您想独立应用它们,请尝试以下操作:
您可以将其包装在一个函数中以便于访问(您仍然必须将句柄传递给线条图形对象):
I don't see a way to do this directly out of the box. The straightforward way is to set the color/style manually for each line.
Here is a more automated solution. Let's start with an example taken from the documentation:
As you explained in your question, the default behavior is to cycle through the colors first, then the line styles. If you want to apply them independently, try the following:
You can maybe wrap that in a function for convenient access (you still have to pass the handles to the lines graphic objects):
Amro 的方法效果很好。请注意,您不必设置默认值即可执行此操作。你可以做这样的事情
编辑:mycolors()函数是自制的。我定义
(颜色名称来自此 http://www.rapidtables.com/web/颜色/RGB_Color.htm)。然后我将它们缩放到 [0,1] 通过
Amro's approach works well. Just as a note, you don't have to set the defaults to do this. You can do something like this
Edit: the mycolors() function is home made. I define
(the color names are from this http://www.rapidtables.com/web/color/RGB_Color.htm). Then I scale them to [0,1] via