question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Powershell Support

See original GitHub issue

Feature Suggestion

Feature description: I have been succesfully using ScottPlot a plotting library in Powershell (both 5 and 7) for quite some time, I don’t know if you want to support this feature, anyway I have written a Powershell Quickstart sample.

Code example:

#[1]
Add-Type -Path .\ScottPlot.dll

[double[]] $dataX = @( 1, 2, 3, 4, 5 )
[double[]] $dataY = @( 1, 4, 9, 16, 25 )
$plt = [ScottPlot.Plot]::new(400, 300)
[Void] $plt.AddScatter($dataX, $dataY)
[Void] $plt.SaveFig("$pwd\quickstart.png")


#[2]
Add-Type -AssemblyName System.Windows.Forms
Add-Type -Path .\ScottPlot.dll
Add-Type -Path .\ScottPlot.WinForms.dll

#https://github.com/ScottPlot/ScottPlot/blob/main/src/ScottPlot4/ScottPlot.Sandbox/WinFormsApp/Form1.Designer.cs

#formsPlot1
$formsPlot1 = [ScottPlot.FormsPlot]::new()
$formsPlot1.Anchor = [System.Windows.Forms.AnchorStyles]::Bottom -bor [System.Windows.Forms.AnchorStyles]::Right -bor [System.Windows.Forms.AnchorStyles]::Top -bor [System.Windows.Forms.AnchorStyles]::Left 
$formsPlot1.BackColor = [System.Drawing.Color]::Transparent
$formsPlot1.Location = [System.Drawing.Point]::new(0, 12)
$formsPlot1.Margin = [System.Windows.Forms.Padding]::new(4, 3, 4, 3)
$formsPlot1.Name = "formsPlot1"
$formsPlot1.Size = [System.Drawing.Size]::new(808, 405)
$formsPlot1.TabIndex = 0

#Form1
$Form1 = [System.Windows.Forms.Form]::new()
$Form1.AutoScaleDimensions = [System.Drawing.SizeF]::new(7, 15)
$Form1.AutoScaleMode = [System.Windows.Forms.AutoScaleMode]::Font
$Form1.ClientSize = [System.Drawing.Size]::new(808, 417)
$Form1.Controls.Add($formsPlot1)
$Form1.Name = "Form1"
$Form1.StartPosition = [System.Windows.Forms.FormStartPosition]::CenterScreen
$Form1.Text = "FormsPlot Sandbox"

#https://github.com/ScottPlot/ScottPlot/blob/main/src/ScottPlot4/ScottPlot.Sandbox/WinFormsApp/Form1.cs

[Void] $formsPlot1.Plot.AddScatter([ScottPlot.DataGen]::Consecutive(51), [ScottPlot.DataGen]::Sin(51))
[Void] $formsPlot1.Plot.AddSignal([ScottPlot.DataGen]::Cos(51))
[Void] $formsPlot1.Plot.AddVerticalLine(25)
[Void] $formsPlot1.Plot.AddText("test 123", 20, .5)
[Void] $formsPlot1.Plot.AddMarker(15, -.5, [ScottPlot.MarkerShape]::openCircle, 20)

[Void] $Form1.ShowDialog()

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
swhardencommented, Jun 6, 2022

Powershell Core is the recommended way

Wow, this was so much easier! I guess Windows PowerShell really lags behind PowerShellCore when it comes to support for modern .NET code. Thanks for pointing this out!

PowerShell Quickstart

Step 1: Get PowerShell Core

Step 2: Build an empty .NET app using ScottPlot

  • dotnet new console
  • dotnet add package scottplot
  • dotnet build

Step 3: Create a PowerShell script

  • Enter the builder folder containing ScottPlot.dll
  • Create myScript.ps1 and copy the following contents into it
  • Run the script using PowerShell Core (not Windows PowerShell)
Add-Type -Path .\ScottPlot.dll
[double[]] $dataX = @( 1, 2, 3, 4, 5 )
[double[]] $dataY = @( 1, 4, 9, 16, 25 )
$plt = [ScottPlot.Plot]::new(400, 300)
[Void] $plt.AddScatter($dataX, $dataY)
[Void] $plt.SaveFig("$pwd\quickstart.png")

quickstart

1reaction
CarloTosocommented, May 21, 2022

Thank you @bclehmann , I’ll edit my markdown.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PowerShell Support Lifecycle
PowerShell is supported under the Microsoft Modern Lifecycle Policy, but support dates are linked to .NET and .NET Core Support Policy. In this ......
Read more >
Microsoft PowerShell - endoflife.date
Check end-of-life, release policy and support schedule for Microsoft PowerShell.
Read more >
PowerShell - Wikipedia
PowerShell's support for .NET Remoting, WS-Management, CIM, and SSH enables administrators to perform administrative tasks on both local and remote Windows ...
Read more >
End of Life for Windows PowerShell 5.1 #16971
Will there be an end-of-life or an end-of-support for Windows PowerShell 5.1? According to this article https://docs.microsoft.com/en-us/ ...
Read more >
PowerShell editing with Visual Studio Code
The Microsoft PowerShell extension for Visual Studio Code (VS Code) provides rich language support and capabilities such as syntax completions, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found