Hello,
I also tried several ways to chart data with a DWSIM script.
But for what I found, matplotlib can't be used, and ironplot library doesn't work (it gives an error that I don't know how to solve).
Eventually I found and adapted a very basic procedure that produces 2D plots with MSChart.
In the attached DWSIM simulation you will find a script that allows to obtain graphs once the data series are populated in the relevant part of the script.
It could be nice to have a charting plugin in the next DWSIM releases.
Hope this helps you.
but I got the error:
Error running script: Traceback (most recent call last):
File "<string>", line 16, in <module>
ValueError: Specified argument was out of the range of valid values.
Parameter name: Type for 'Eto.OxyPlot.Plot' could not be found in this platform </module></string>
Any suggestion? (I am using DW 5.7u14)
Thanks
Luca
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry guys, the code in the dynamic tutorial only works on the Cross-Platform UI. For the Classic UI (Windows Forms), try the following:
importsyssys.path.append(r"./Lib")importsiteimportosimportclrclr.AddReference("OxyPlot")clr.AddReference("OxyPlot.WindowsForms")clr.AddReference("System.Windows.Forms")clr.AddReference("DWSIM.ExtensionMethods.Eto")importOxyPlotfromOxyPlot.WindowsFormsimportPlotViewfromSystem.Windows.Formsimport*fromDWSIM.UI.Sharedimport*fromSystemimportArrayfrommathimport*x=[i*0.1foriinrange(100)]# generate and display a nice chart# create a new Plot model# http://dwsim.inforside.com.br/api_help5/html/T_DWSIM_UI_Shared_Common.htm# http://dwsim.inforside.com.br/api_help5/html/T_DWSIM_ExtensionMethods_OxyPlot.htmchart1=PlotView()chart1.Model=Common.CreatePlotModel(Array[float](x),Array[float]([sin(xi)forxiinx]),"Test","","x","y")# update the chart data viewchart1.Model.InvalidatePlot(True)# setup and display the chartform1=Form()chart1.Dock=DockStyle.Fillform1.Controls.Add(chart1)form1.Invalidate()form1.Show()
👍
1
Last edit: Daniel Medeiros 2019-08-11
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
How can i create a 2-dimensional plot in DWSIM given 2 arrays of same size?
On Python?
Hello,
I also tried several ways to chart data with a DWSIM script.
But for what I found, matplotlib can't be used, and ironplot library doesn't work (it gives an error that I don't know how to solve).
Eventually I found and adapted a very basic procedure that produces 2D plots with MSChart.
In the attached DWSIM simulation you will find a script that allows to obtain graphs once the data series are populated in the relevant part of the script.
It could be nice to have a charting plugin in the next DWSIM releases.
Hope this helps you.
Luca
Thanks a lot Luca Finardi
Guys, check the dynamic simulation tutorial, there are a lot of 2d charting examples on it.
Thanks Daniel for addressing to OxyPlot included in the Dynamic tutorial.
However I could not make it it working. I tried this simple:
import sys
sys.path.append(r"./Lib")
import site
import os
import clr
clr.AddReference("Eto.OxyPlot")
clr.AddReference("OxyPlot")
import OxyPlot
from Eto.OxyPlot import Plot
from math import *
x = [i * 0.1 for i in range(100)]
chart1 = Plot()
chart1.Model = Common.CreatePlotModel(x, [sin(xi) for xi in x], "Plot1", "", "x", "Sin(x)")
chart1.Model.InvalidatePlot(True)
form1 = Common.GetDefaultEditorForm("Test", 600, 600, chart1, False)
form1.Show()
but I got the error:
Error running script: Traceback (most recent call last):
File "<string>", line 16, in <module>
ValueError: Specified argument was out of the range of valid values.
Parameter name: Type for 'Eto.OxyPlot.Plot' could not be found in this platform </module></string>
Any suggestion? (I am using DW 5.7u14)
Thanks
Luca
Sorry guys, the code in the dynamic tutorial only works on the Cross-Platform UI. For the Classic UI (Windows Forms), try the following:
Last edit: Daniel Medeiros 2019-08-11
Thanks Daniel for this clarification.
I tried your example with the classic UI, but to me it only shows an empty form (see attachment).
Try resizing the form. The Invalidate() call is responsible for updating the form contents. I've tested it here and it worked as expected.
Here instead the form does not resize and after a while disappears.