library(mosaicCalc)
## Loading required package: mosaic
## Registered S3 method overwritten by 'mosaic':
##   method                           from   
##   fortify.SpatialPolygonsDataFrame ggplot2
## 
## The 'mosaic' package masks several functions from core packages in order to add 
## additional features.  The original behavior of these functions should not be affected by this.
## 
## Attaching package: 'mosaic'
## The following objects are masked from 'package:dplyr':
## 
##     count, do, tally
## The following object is masked from 'package:Matrix':
## 
##     mean
## The following object is masked from 'package:ggplot2':
## 
##     stat
## The following objects are masked from 'package:stats':
## 
##     binom.test, cor, cor.test, cov, fivenum, IQR, median, prop.test,
##     quantile, sd, t.test, var
## The following objects are masked from 'package:base':
## 
##     max, mean, min, prod, range, sample, sum
## Loading required package: mosaicCore
## 
## Attaching package: 'mosaicCore'
## The following objects are masked from 'package:dplyr':
## 
##     count, tally
## 
## Attaching package: 'mosaicCalc'
## The following object is masked from 'package:stats':
## 
##     D
##Loading required package: mosaic
##Registered S3 method overwritten by 'mosaic'
##method                              from
##fortify.SpatialPolygonsDataFrame ggplot2
##
##The 'mosaic' package masks several functions from core packages in order to add
##additional features. The original behavior of these functions should not be affected by this.
##
##Attaching package: 'mosaic'
## The following objects are masked from 'package:dplyr':
## 
##     count, do, tally
## The following object is masked from 'package:Matrix':
## 
##     mean
## The following object is masked from 'package:ggplot2':
## 
##     stat
## The following objects are masked from 'package:stats':
## 
##     binom.test, cor, cor.test, cov, fivenum, IQR, median, prop.test,
##     quantile, sd, t.test, var
## The following objects are masked from 'package:base':
## 
##     max, mean, min, prod, range, sample, sum
## Loading required package: mosaicCore
## 
## Attaching package: 'mosaicCore'
## The following objects are masked from 'package:dplyr':
## 
##     count, tally
## 
## Attaching package: 'mosaicCalc'
## The following object is masked from 'package:stats':
## 
##     D

Ada tiga fungsi grafik {mosaicCalc}yang memungkinkan untuk membuat grafik fungsi, dan melapisi plot tersebut dengan grafik fungsi atau data lain. Ini adalah:

slice_plot()untuk fungsi satu variabel. contour_plot()untuk fungsi dua variabel. interactive_plot()yang menghasilkan widget HTML untuk berinteraksi dengan fungsi dua variabel. Ketiganya digunakan dengan cara yang hampir sama. Berikut adalah contoh memplot fungsi garis lurus:

slice_plot(4 * x - 6 ~ x, domain(x = range(0, 18)))

m = -7
b = -2
slice_plot(m * x + b ~ x, domain(x = range(0, 20)))

kita juga dapat memberi nama suatu fungsi dengan makeFun seperti contoh:

g  <- makeFun(3*x^3 - 7*x + 4 ~ x)
slice_plot(g(x) ~ x , domain(x = range(-5, 5)))

kita juga dapat membuat fungsi yang rumit seperti contoh:

slice_plot( cos(6 * x) ~ x, domain(x = range(-4, 4)))