Description Usage Arguments Details See Also Examples

Add a function to plot.

1 2 3 4 5 6 7 8 9 10 11 | ```
fun_add(p, fun, samples = NULL, closed = FALSE, color = NULL,
type = NULL, range = NULL, tip = FALSE, ...)
fun_add_param(p, x, y, samples = NULL, closed = FALSE, color = NULL,
type = "polyline", range = NULL, tip = FALSE, ...)
fun_add_polar(p, r, scope = NULL, samples = NULL, closed = FALSE,
color = NULL, type = "polyline", range = NULL, tip = FALSE, ...)
fun_add_imp(p, fun, samples = NULL, closed = FALSE, color = NULL,
type = NULL, range = NULL, tip = FALSE, ...)
``` |

`p` |
Plot as initialised by |

`fun` |
Function to plot. |

`samples` |
Determine the number of equally spaced points in which the function will be evaluated in the current domain, increasing it will more accurately represent the function using rectangles at the cost of processing speed. |

`closed` |
Set to |

`color` |
Color. |

`type` |
Rhree representations of functions, default to |

`range` |
A |

`tip` |
Set to |

`...` |
Any other parameter. |

`x, y` |
Parametric equation. |

`r` |
Polar equation. |

`scope` |
Scope of |

Valid `type`

values:

`polyline`

where*f(x)*is evaluated with some*x*values, after the evaluation the points are joined with line segments using`<path>`

s`scatter`

where*f(x)*is evaluated with some*x*values, after the evaluation the points are represented by`<circle>`

s`interval`

where*f(x)*is evaluated with intervals instead of a single point, after the evaluation 2d rects are painted on the screen (done using the`<path>`

svg element)

`fun`

:

Plotting roots can be a challenging problem, most plotters will actually analyze expression of the type *x^{a/b}*,
particularly they will analyze the denominator of the exponent (to plot in the negative x-axis),
interval-arithmetic and math.js come bundled with a useful `nthRoot`

function to solve these issues.

`fun_secants`

, `fun_deriv`

, `fun_scope`

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 | ```
# basic equation
funplot() %>%
fun_add(fun = "sin(x)")
# parametric equation
funplot() %>%
fun_add_param(
x = "sin(t) * (exp(cos(t)) - 2 cos(4t) - sin(t/12)^5)",
y = "cos(t) * (exp(cos(t)) - 2 cos(4t) - sin(t/12)^5)"
)
# polar equation
funplot() %>%
fun_add_polar(r = "2 * sin(4 theta)")
# implicit function
funplot() %>%
fun_add_imp("cos(PI * x) - cos(PI * y)")
# multiple functions
funplot() %>%
fun_add("sqrt(1 - x * x)") %>%
fun_add("-sqrt(1 - x * x)")
# samples
funplot() %>%
fun_add(fun = "sin(x)", samples = 1000)
# closed = TRUE
funplot() %>%
fun_add("1/x * cos(1/x)", closed = TRUE) %>%
fun_x("log", domain = list(0.01, 1)) %>%
fun_y(domain = list(-100, 100))
# color and type
funplot() %>%
fun_add("x", color = "black") %>%
fun_add("-x") %>%
fun_add("-sqrt(x)", type = "scatter", samples = 100) %>%
fun_add("sqrt(x)", tip = TRUE)
# nthRoot
funplot() %>%
fun_add("nthRoot(x, 3)^2")
# derivative
funplot() %>%
fun_add("x^2") %>%
fun_deriv("2 * x", mouse = TRUE)
# secants
funplot() %>%
fun_add("x^2") %>%
fun_secants(x0 = 5, mouse = TRUE)
``` |

JohnCoene/funplot documentation built on March 19, 2018, 5:07 a.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.