asc-community / asc-community/AngouriMath
[WIP] Redesign plotting API
- Dominant language
- C#
- Stars
- 831
- Forks
- 79
- Avg merge
- 3h 23m
- Merged PRs (30d)
- 309
Description
# Plotting API
Since 1.4 preview 1 one now can plot functions in "experimental"/preview mode. Time to make it prettier!
## Root types
Will be in class `Plot`:
```fs
module AngouriMath.Interactive
...
type AnyFunc = obj
type AnyVar = obj
...
type Plot =
... // here the static members come
```
## 2D
### Signature
```fs
static member plottingFunction(func : AnyFunc,
[] ?var : AnyVar,
[] ?range : double seq
) : GenericChart
```
### Functions
| Function | Default range |
|-----|---|
| `cartesianLine` | `[-1.0..0.01..1.0]` |
| `cartesianScatter2D` | `[-1.0..0.01..1.0]` |
| `polarLine` | `[0.0..0.01..3.1415]` |
| `polarScatter` | `[0.0..0.01..3.1415]` |
## 3D
### Signature
```fs
static member plottingFunction(func : AnyFunc,
[] ?var1 : AnyVar,
[] ?var2 : AnyVar,
[] ?range1 : double seq,
[] ?range2 : double seq
) : GenericChart
```
If no `var` was specified, they're taken from the expression in the alphabet order, e. g. for `y + x` the variables will be `x` and `y`.
### Functions
| Function | Default range 1 | Default range 2 |
|-----|---|---|
| `cartesianSurface` | `[-1.0..0.05..1.0]` | `[-1.0..0.05..1.0]` |
| `cartesianScatter3D` | `[-1.0..0.05..1.0]` | `[-1.0..0.05..1.0]` |
| `sphericalSurface` | `[0.0..0.05..3.1415]` | `[0.0..0.05..3.1415]` |
| `sphericalScatter` | `[0.0..0.05..3.1415]` | `[0.0..0.05..3.1415]` |
| `cylindricalSurface` | `[0.0..0.05..3.1415]` | `[0.0..0.05..1.0]` |
| `cylindricalScatter` | `[0.0..0.05..3.1415]` | `[0.0..0.05..1.0]` |
## Sliders
### For 2D
```fs
static member withSlider2D(func : AnyFunc,
plottingFunc : (AnyFunc * AnyVar Option * double seq option) -> GenericChart,
[] ?var : AnyVar,
[] ?range : double seq,
[] ?param : AnyVar,
[] ?paramRange : double seq,
) : GenericChart
```
If no parameter and argument is specified, the variables taken from the expression are ordered in alphabet order, and the parameter is the **first** of them. For example, in `x + a` the paramater is `a` and the variable is `x`.
The default value for `range` now is `[1.0..0.1..2.0]`, but no default value for `range` (it will be passed as-is).
### For 3D
```fs
static member withSlider3D(func : AnyFunc,
plottingFunc : (AnyFunc * AnyVar Option * AnyVar Option * double seq Option * double seq Option) -> GenericChart,
[] ?var1 : AnyVar,
[] ?var2 : AnyVar,
[] ?range1 : double seq,
[] ?range2 : double seq,
[] ?param : AnyVar,
[] ?paramRange : double seq,
) : GenericChart
```
Likewise, the `param` variable is defined as the first one by alphabet by default.
## Unresolved questions
Can we let input expressions? e. g. `range = [ 0.0..0.1.. (2 * pi) ]`
Contributor guide
Assessment
This issue has not been assessed yet.