-
Notifications
You must be signed in to change notification settings - Fork 81
/
12_1_smith_line_scatter_plots.fsx
118 lines (86 loc) · 3.2 KB
/
12_1_smith_line_scatter_plots.fsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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, 2.0.0"
#r "../src/Plotly.NET/bin/Release/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***)