plot - 如何理解 SciLab 中的“孩子”?
问题描述
clc
x = [1:1:10];
y1 = x;
y2 = 2*x;
y3 = 3*x;
plot2d(x,y1);
plot2d(x,y2);
plot2d(x,y3)
gca().children(1).children(1).thickness = 2
gca().children(2).children(1).thickness = 7
gca().children(3).children(1).thickness = 4
我是从 Matlab 到 Scilab 的新手
谁能告诉我,如何理解孩子?
什么意思
gca().children
?
gca().children.children
?
gca().children.children(1)
?
gca().children(1).children
?
我们如何知道哪个属性属于 children ?
e.g gca().children(1).children(1).color = ... // not exist
我现在很困惑..提前谢谢
解决方案
让我们通过它们的子属性来图解嵌套的图形对象。
我们有
figure (f)
- axes (a)
- compound1 (c1)
- polyline (p1)
- compound2 (c2)
- polyline (p2)
- compound3 (c3)
- polyline (p3)
由于 gca 是一个函数,a = gca()
因此gca().children
会引发错误,因为 scilab 不了解您正在尝试访问其返回值的字段。
gca()
将句柄返回到当前图窗的轴:a
。a.children
返回这些轴的所有子句柄的数组。:c1, c2, c3
a.children.children
返回上述对象的所有子句柄的数组:p1, p2, p3
a.children.children(1)
返回 的第一个孩子c1, c2, c3
:p1
a.children(1).children
返回当前坐标区 (c1) 的第一个子级的所有子级。因为只有一个:p1
访问您的实体的价值
要么选择一个临时变量:
a = gca();
idcolor=a.children(1).children(1).foreground // gives the color of a.c1.p1
或使用get
// idcolor is an array , with idcolor(i) the color of pi
idcolor = get(get(get(gca(),'children'),'children'),'foreground')
供参考
gce()
命令返回最后创建的对象的句柄。使用 plot2d 它是一个化合物,所以我们需要得到它的孩子。
你可以将你的程序重写为
clc
x = [1:1:10];
y1 = x;
y2 = 2*x;
y3 = 3*x;
plot2d(x,y1);
e1 = get(gce(),'children');
plot2d(x,y2);
e2 = get(gce(),'children');
plot2d(x,y3)
e3 = get(gce(),'children');
e1.thickness = 2
e2.thickness = 7
e3.thickness = 4
推荐阅读
- c# - MongoDatabase 和 MongoCollection 可以是单例吗
- java - 如何使用递归在 Java 中制作负斐波那契数列?
- sql - 如何在 SQL 查询中使用最大日期
- angular - 在 Angular 中最小化 vendor.bundje.js
- android - 这些下划线在 kotlin 中是什么意思?
- ios - 使用 Firebase 数据消息时,通知服务扩展不处理数据消息
- javascript - esri-leaflet-geosearch:如何将其与 React 集成
- c# - 如何在 http 调用中将 C# 变量作为参数传递给 php 脚本
- react-native - React Native 中底部导航的边框底部
- jquery - jQuery Form Builder 配置精细上传器