matlab - How to assign different colors to each data set using plotpv?
问题描述
I am studying neural networks and I need to know if it is possible to show datasets with different colors using the plotpv function.
I was assigned a homework task in which I separated two sets of data with a straight line (both sets are linearly separable by the calculations thrown by a perceptron.) If I'm not wrong, plotpv uses the symbols (+) and (or) by default for P and T (the names of both data sets).
The homework asks us to show each set of similar data with its own color, but I can not find a way to assign a different color to each data. Everything is shown in blue. I have thought about copying the code of the plotpv function and looking at where each element is shown to change the color of one of the two sets.
I guess that it would be useful tell you that I found a similar case related to plotpc, but that case has not provided me with enough information to determine how to do what is requested in the homework. This is the link:
Different color line with plotpc in matlab
I don't have any code to show you. I have few experience in MATLAB. Also, I suppose that the solution would has few lines, rigth?
I would like to get red +'s and blue o's.... (for example)
解决方案
就输出样式而言,plotpv
它不是很有帮助,因为它不会将句柄返回到绘制的对象。但是,您可以将它们作为相应axes
.
以下代码将 s 的MarkerEdgeColor
-property设置o
为 red 和+
black。
% plot data
p = [0 0 1 1; 0 1 0 1];
t = [0 0 0 1];
plotpv(p,t)
% change colors
ax = gca
for i = allchild(ax)'
switch i.Marker
case '+'
i.MarkerEdgeColor = 'k';
case 'o'
i.MarkerEdgeColor = 'r';
end
end
推荐阅读
- facebook - Facebook:使用公共 URL 共享唯一图像并在本地丢弃图像。是不是一直在FB?
- spring-batch - 为什么不将 Spring Data JPA 与批处理一起使用?
- php - Laravel - 如何使用对象数组制作多过滤器?
- c# - 如何使用 Media Foundation 修复曝光过度的高分辨率照片?
- java - 结合调度器和执行器服务的咖啡因
- javascript - Gem Chartkick 图表未在 PDF 上呈现
- wordpress - WordPress:为什么博客页面的永久链接是最新的博客文章
- python - 在使用 python SDK 创建 Azure VM 时添加 SSH 密钥
- ruby-on-rails - 解析 database.yml 文件时出现 YAML 语法错误
- arrays - c - 与数组函数一起使用时 (int *)s 是什么意思