Skip to content

Add Smith Charts #270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Plotly.NET.sln
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{7B09CC0A-F
docs\10_1_styling_ternary_layouts.fsx = docs\10_1_styling_ternary_layouts.fsx
docs\11_1_carpet_line_scatter_plots.fsx = docs\11_1_carpet_line_scatter_plots.fsx
docs\11_2_contourcarpet_plots.fsx = docs\11_2_contourcarpet_plots.fsx
docs\12_1_smith_line_scatter_plots.fsx = docs\12_1_smith_line_scatter_plots.fsx
docs\_template.fsx = docs\_template.fsx
docs\_template.html = docs\_template.html
docs\_template.ipynb = docs\_template.ipynb
Expand Down
58 changes: 50 additions & 8 deletions docs/01_2_multiple-charts.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -252,20 +252,62 @@ open Plotly.NET.LayoutObjects

let multipleTraceTypesGrid =
[
Chart.Point([1,2; 2,3])
Chart.PointTernary([1,2,3; 2,3,4])
Chart.Heatmap([[1; 2];[3; 4]], ShowScale=false)
Chart.Point3D([1,3,2])
Chart.PointMapbox([1,2]) |> Chart.withMapbox(Mapbox.init(Style = StyleParam.MapboxStyle.OpenStreetMap))
Chart.Point([1,2; 2,3], Name = "2D Cartesian")
Chart.Point3D([1,3,2], Name = "3D Cartesian")
Chart.PointPolar([10,20], Name = "Polar")
Chart.PointGeo([1,2], Name = "Geo")
Chart.PointMapbox([1,2], Name = "MapBox") |> Chart.withMapbox(Mapbox.init(Style = StyleParam.MapboxStyle.OpenStreetMap))
Chart.PointTernary([1,2,3; 2,3,4], Name = "Ternary")
[
Chart.Carpet(
"contour",
A = [0.; 1.; 2.; 3.; 0.; 1.; 2.; 3.; 0.; 1.; 2.; 3.],
B = [4.; 4.; 4.; 4.; 5.; 5.; 5.; 5.; 6.; 6.; 6.; 6.],
X = [2.; 3.; 4.; 5.; 2.2; 3.1; 4.1; 5.1; 1.5; 2.5; 3.5; 4.5],
Y = [1.; 1.4; 1.6; 1.75; 2.; 2.5; 2.7; 2.75; 3.; 3.5; 3.7; 3.75],
AAxis = LinearAxis.initCarpet(
TickPrefix = "a = ",
Smoothing = 0.,
MinorGridCount = 9,
AxisType = StyleParam.AxisType.Linear
),
BAxis = LinearAxis.initCarpet(
TickPrefix = "b = ",
Smoothing = 0.,
MinorGridCount = 9,
AxisType = StyleParam.AxisType.Linear
),
Opacity = 0.75
)
Chart.ContourCarpet(
[1.; 1.96; 2.56; 3.0625; 4.; 5.0625; 1.; 7.5625; 9.; 12.25; 15.21; 14.0625],
"contour",
A = [0; 1; 2; 3; 0; 1; 2; 3; 0; 1; 2; 3],
B = [4; 4; 4; 4; 5; 5; 5; 5; 6; 6; 6; 6],
ContourLineColor = Color.fromKeyword White,
ShowContourLabels = true,
ShowScale = false
)
]
|> Chart.combine
Chart.Pie([10;40;50;], Name = "Domain")
Chart.BubbleSmith(
[0.5; 1.; 2.; 3.],
[0.5; 1.; 2.; 3.],
sizes = [10;20;30;40],
MultiText=["one";"two";"three";"four";"five";"six";"seven"],
TextPosition=StyleParam.TextPosition.TopCenter,
Name = "Smith"
)
[
// you can use nested combined charts, but they have to have the same trace type (Cartesian2D in this case)
let y = [2.; 1.5; 5.; 1.5; 2.; 2.5; 2.1; 2.5; 1.5; 1.;2.; 1.5; 5.; 1.5; 3.; 2.5; 2.5; 1.5; 3.5; 1.]
Chart.BoxPlot("y" ,y,Name="bin1",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All);
Chart.BoxPlot("y'",y,Name="bin2",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All);
Chart.BoxPlot("y" ,y,Name="Combined 1",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All);
Chart.BoxPlot("y'",y,Name="Combined 2",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All);
]
|> Chart.combine
]
|> Chart.Grid(2,3)
|> Chart.Grid(4,3)
|> Chart.withSize(1000,1000)

(*** condition: ipynb ***)
Expand Down
118 changes: 118 additions & 0 deletions docs/12_1_smith_line_scatter_plots.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
(**
---
title: Smith line and scatter plots
category: Smith Plots
categoryindex: 13
index: 1
---
*)

(*** hide ***)

(*** condition: prepare ***)
#r "nuget: Newtonsoft.JSON, 13.0.1"
#r "nuget: DynamicObj, 1.0.1"
#r "../bin/Plotly.NET/netstandard2.0/Plotly.NET.dll"

(*** condition: ipynb ***)
#if IPYNB
#r "nuget: Plotly.NET, {{fsdocs-package-version}}"
#r "nuget: Plotly.NET.Interactive, {{fsdocs-package-version}}"
#endif // IPYNB

(**
# Smith charts

[![Binder]({{root}}img/badge-binder.svg)](https://mybinder.org/v2/gh/plotly/Plotly.NET/gh-pages?filepath={{fsdocs-source-basename}}.ipynb) 
[![Script]({{root}}img/badge-script.svg)]({{root}}{{fsdocs-source-basename}}.fsx) 
[![Notebook]({{root}}img/badge-notebook.svg)]({{root}}{{fsdocs-source-basename}}.ipynb)

*Summary:* This example shows how to create smith charts in F#.

let's first create some data for the purpose of creating example charts:

*)

open Plotly.NET

// real coordinates
let real = [0.5; 1.; 2.; 3.]

// imaginary coordinates
let imaginary = [0.5; 1.; 2.; 3.]

(**
The Smith chart, invented by Phillip H. Smith (1905�1987) and independently by Mizuhashi Tosaku, is a graphical calculator or nomogram designed for electrical and electronics engineers specializing in radio frequency (RF) engineering to assist in solving problems with transmission lines and matching circuits

The Smith chart is a mathematical transformation of the two-dimensional Cartesian complex plane. Complex numbers with positive real parts map inside the circle. Those with negative real parts map outside the circle. If we are dealing only with impedances with non-negative resistive components, our interest is focused on the area inside the circle.

([Wikipedia](https://en.wikipedia.org/wiki/Smith_chart)).

Still, you can plot any kind of imaginary numbers on this plane.

## point smith charts

use `Chart.PointSmith` to create a chart that displays points on a smith subplot:
*)

let pointSmith = Chart.PointSmith(real,imaginary)
(*** condition: ipynb ***)
#if IPYNB
pointSmith
#endif // IPYNB

(***hide***)
pointSmith |> GenericChart.toChartHTML
(***include-it-raw***)

(**
## line smith charts

use `Chart.LineSmith` to create a plot that displays a line connecting the data on a smith subplot.

This example also changes the styles of the line.
*)

let lineSmith =
Chart.LineSmith(
real,
imaginary,
LineDash = StyleParam.DrawingStyle.DashDot,
LineColor = Color.fromKeyword Purple
)


(*** condition: ipynb ***)
#if IPYNB
lineSmith
#endif // IPYNB

(***hide***)
lineSmith |> GenericChart.toChartHTML
(***include-it-raw***)

(**
## bubble smith charts

use `Chart.BubbleSmith` to create a plot that displays datums on a smith subplot, with an additional 3rd dimension set as the marker size.

As for all other plots above, You can for example add labels to each datum:
*)

let bubbleSmith =
Chart.BubbleSmith(
real,
imaginary,
sizes = [10;20;30;40],
MultiText=["one";"two";"three";"four";"five";"six";"seven"],
TextPosition=StyleParam.TextPosition.TopCenter
)

(*** condition: ipynb ***)
#if IPYNB
bubbleSmith
#endif // IPYNB

(***hide***)
bubbleSmith |> GenericChart.toChartHTML
(***include-it-raw***)
Loading