scilab 中的线条样式和粗细问题
line style and thickness issue in scilab
我正在尝试绘制五个不同的子图,每个子图由四个不同的线条组成。我正在使用代码 f.children.children(1).children.line_style = 2;
f.children.children(1).children.thickness = 2;
更改线型和粗细。它仅适用于一个情节。在子图的情况下,它会给出维度不一致的错误。我在这里写的不是我的代码,而是一个简单的代码,它也给出了同样的错误。如果有人在这里帮助我,将不胜感激。代码是
clear;clc
p = 0:100; t1 = p.^3; t2 = 3*p.^3-5; //functions defined
clf(); f=gcf();
subplot(221);
plot2d(p, t1, 3); //function t1 plotted at (221)
f.children.children(1).children.line_style = 1;
f.children.children(1).children.thickness = 2;
//----------------------------------------------------------------------
plot2d(p, t2, 9); //function t2 plotted with t1 at (221)
f.children.children(1).children.line_style = 2;
f.children.children(1).children.thickness = 2;
//**********************************************************************
x = 1:100; y1 = 2*x-5; y2 = 10*x+100; //functions y1 and y2 defined
subplot(222);
plot2d(x, y1, 6); //function y1 plotted at (222)
f.children.children(1).children.line_style = 1;
f.children.children(1).children.thickness = 2;
//----------------------------------------------------------------------
plot2d(x, y2, 5); //function y2 plotted with y1 at (222)
f.children.children(1).children.line_style = 2;
f.children.children(1).children.thickness = 2;
//**********************************************************************
r = 1:100; z1 = 2*r^2-5; z2 = r.^2; //functions z1 and z2 aredefined
subplot(223)
plot2d(r, z1, 1); //function z1 plotted at (223)
f.children.children(1).children.line_style = 6;
f.children.children(1).children.thickness = 2;
//---------------------------------------------
plot2d(r, z2, 3); //function z2 plotted with z1 at (223)
f.children.children(1).children.line_style = 2;
f.children.children(1).children.thickness = 2;
我不明白为什么要使用 gcf
your current code fails. But I would use gce
来获取最后一个实体。
我会介绍一个功能来设置线型和粗细,删除很多重复。
示例代码
clear;clc
p = 0:100; t1 = p.^3; t2 = 3*p.^3-5; //functions defined
clf(); f=gcf();
function set_my_line_styles(style, thickness)
e = gce();
e.children.line_style = style;
e.children.thickness = thickness;
endfunction
subplot(221);
plot2d(p, t1, 3); //function t1 plotted at (221)
set_my_line_styles(1,2);
//----------------------------------------------------------------------
plot2d(p, t2, 9); //function t2 plotted with t1 at (221)
set_my_line_styles(2,2);
//**********************************************************************
x = 1:100; y1 = 2*x-5; y2 = 10*x+100; //functions y1 and y2 defined
subplot(222);
plot2d(x, y1, 6); //function y1 plotted at (222)
set_my_line_styles(1,2);
//----------------------------------------------------------------------
plot2d(x, y2, 5); //function y2 plotted with y1 at (222)
set_my_line_styles(2,2);
//**********************************************************************
r = 1:100; z1 = 2*r^2-5; z2 = r.^2; //functions z1 and z2 aredefined
subplot(223)
plot2d(r, z1, 1); //function z1 plotted at (223)
set_my_line_styles(6,2);
//---------------------------------------------
plot2d(r, z2, 3); //function z2 plotted with z1 at (223)
set_my_line_styles(2,2);
结果图
我正在尝试绘制五个不同的子图,每个子图由四个不同的线条组成。我正在使用代码 f.children.children(1).children.line_style = 2;
f.children.children(1).children.thickness = 2;
更改线型和粗细。它仅适用于一个情节。在子图的情况下,它会给出维度不一致的错误。我在这里写的不是我的代码,而是一个简单的代码,它也给出了同样的错误。如果有人在这里帮助我,将不胜感激。代码是
clear;clc
p = 0:100; t1 = p.^3; t2 = 3*p.^3-5; //functions defined
clf(); f=gcf();
subplot(221);
plot2d(p, t1, 3); //function t1 plotted at (221)
f.children.children(1).children.line_style = 1;
f.children.children(1).children.thickness = 2;
//----------------------------------------------------------------------
plot2d(p, t2, 9); //function t2 plotted with t1 at (221)
f.children.children(1).children.line_style = 2;
f.children.children(1).children.thickness = 2;
//**********************************************************************
x = 1:100; y1 = 2*x-5; y2 = 10*x+100; //functions y1 and y2 defined
subplot(222);
plot2d(x, y1, 6); //function y1 plotted at (222)
f.children.children(1).children.line_style = 1;
f.children.children(1).children.thickness = 2;
//----------------------------------------------------------------------
plot2d(x, y2, 5); //function y2 plotted with y1 at (222)
f.children.children(1).children.line_style = 2;
f.children.children(1).children.thickness = 2;
//**********************************************************************
r = 1:100; z1 = 2*r^2-5; z2 = r.^2; //functions z1 and z2 aredefined
subplot(223)
plot2d(r, z1, 1); //function z1 plotted at (223)
f.children.children(1).children.line_style = 6;
f.children.children(1).children.thickness = 2;
//---------------------------------------------
plot2d(r, z2, 3); //function z2 plotted with z1 at (223)
f.children.children(1).children.line_style = 2;
f.children.children(1).children.thickness = 2;
我不明白为什么要使用 gcf
your current code fails. But I would use gce
来获取最后一个实体。
我会介绍一个功能来设置线型和粗细,删除很多重复。
示例代码
clear;clc
p = 0:100; t1 = p.^3; t2 = 3*p.^3-5; //functions defined
clf(); f=gcf();
function set_my_line_styles(style, thickness)
e = gce();
e.children.line_style = style;
e.children.thickness = thickness;
endfunction
subplot(221);
plot2d(p, t1, 3); //function t1 plotted at (221)
set_my_line_styles(1,2);
//----------------------------------------------------------------------
plot2d(p, t2, 9); //function t2 plotted with t1 at (221)
set_my_line_styles(2,2);
//**********************************************************************
x = 1:100; y1 = 2*x-5; y2 = 10*x+100; //functions y1 and y2 defined
subplot(222);
plot2d(x, y1, 6); //function y1 plotted at (222)
set_my_line_styles(1,2);
//----------------------------------------------------------------------
plot2d(x, y2, 5); //function y2 plotted with y1 at (222)
set_my_line_styles(2,2);
//**********************************************************************
r = 1:100; z1 = 2*r^2-5; z2 = r.^2; //functions z1 and z2 aredefined
subplot(223)
plot2d(r, z1, 1); //function z1 plotted at (223)
set_my_line_styles(6,2);
//---------------------------------------------
plot2d(r, z2, 3); //function z2 plotted with z1 at (223)
set_my_line_styles(2,2);