【问题标题】:Scilab : add legend for surface plotScilab:为曲面图添加图例
【发布时间】:2015-01-13 08:31:06
【问题描述】:

我想在曲面图中添加一个图例。 我试过了,这样做:

X=[0:0.3:2*%pi];   //example data
[x,y]=ndgrid(X,X);
z1=sin(X')*cos(X);
z2=z1/2;
z3=z1/3;
figure=scf();
surf(x,y,z1);
surf(x,y,z2);
surf(x,y,z3);
axes=figure.children(1);
axes.children(1).foreground=color(0,0,0);
axes.children(2).foreground=color(0,0,0);
axes.children(3).foreground=color(255,0,0);
axes.children(1).color_flag=0;
axes.children(2).color_flag=0;
axes.children(3).color_flag=0;
axes.children(1).color_mode=color(0,255,0);
axes.children(2).color_mode=color(0,0,255);
axes.children(3).color_mode=0;
legend(['z1','z1 divided by 2','z1 divided by 3'],opt=2,font_size=2);

我收到以下错误消息:

 !--error 10000 
legend : Neither handle of type 'Polyline' can be found.

如果无法使用 Scilab 的基本版本执行此操作,请您告诉我一些 Scilab 允许执行此操作的库。

感谢您的帮助。

【问题讨论】:

    标签: graph legend polyline scilab surface


    【解决方案1】:

    图例无法用于曲面图

    Legends 仅适用于 documentation of legend properties 中所述的 plot2dx 图形:

    这个实体定义了在 plot2dx 下面绘制的图例的参数 图表或由标题功能创建。

    替代方案

    你可以简单地使用xtitle添加一个标题

    xtitle('z1,z1 div by2, z2 div by 3');
    

    您可以使用uicontrol 绘制一个框并使用uicontrol_properties 设置样式:

    fig = gcf();
    uicontrol(fig, "style", "text", ...
                   "string", "<html>z1<br>z1/2<br>z1/3</html>", ...
                   "position",[100 100 100 100], ...
                   "fontsize",15);
    

    【讨论】:

      猜你喜欢
      • 2021-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-11
      • 1970-01-01
      • 2019-08-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多