【问题标题】:Adding extra vertical line to the existing Dymola plot向现有 Dymola 图添加额外的垂直线
【发布时间】:2020-01-27 15:36:28
【问题描述】:

我有一个看起来像这样的图表:

请注意,x 轴不是时间,而是任意自变量。

我需要绘制上图所示的垂直线并标记它们。如何在 Dymola 中使用 mos 脚本完成此操作?

谢谢!

【问题讨论】:

    标签: plot modelica dymola openmodelica


    【解决方案1】:

    除了通过plotArray() 手动添加一行plotText() 随附的文本外,我找不到其他任何东西。请参阅下面的特定于 Dymola 的 .mos-script,该脚本应在末尾生成绘图。

    // Simulate the model
    simulateModel("Modelica.Mechanics.Rotational.Examples.CoupledClutches", stopTime=1.5, numberOfIntervals=0, outputInterval=0.001, resultFile="CoupledClutches");
    
    // Create the actual plot
    createPlot(id=1, position={191, 39, 672, 423}, x="clutch1.tau", y={"clutch1.phi_rel", "clutch1.w_rel"}, range={-10.0, 4.0, -200.0, 20.0}, grid=true, colors={{28,108,200}, {238,46,47}}, displayUnits={"deg", ""});
    
    // Add the vertical line
    plotArray(x={-8,-8},y={-200,0},color={0,128,0},thickness=0.5, erase=false);
    plotArray(x={-2,-2},y={-200,0},color={128,0,128},thickness=0.5, erase=false);
    
    // Add text
    plotText(id=1, extent={{-9,-210}, {-7,-220}}, textString="Description 01", lineColor={0,128,0});
    plotText(id=1, extent={{-3,-210}, {-1,-220}}, textString="Description 02", lineColor={128,0,128});
    

    如果您想像在模型中那样使用图例进行描述,请使用plotArray()-函数的“legend”字符串参数,而不是手动添加文本。

    该脚本肯定可以通过一些更复杂的数组和文本维度来增强,但这应该是一个很好的起点。也可以使用plotArrays() 组合垂直线。

    【讨论】:

      猜你喜欢
      • 2018-05-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-22
      • 2022-09-24
      • 2019-09-07
      • 1970-01-01
      相关资源
      最近更新 更多