Plot methods for bv (bivariate) and tv (trivariate) objects.
Note that you can use the standard plot function.
Also, note that the misc3d package needs to be installed and loaded, in order to plot the trivariate normal distribution.
########################################
#discrete uniform
########################################
# S3 method for DUBVPMF
bv.plotf(f, in3d=TRUE, …, xlim, ylim, all=FALSE)
# S3 method for DUBVCDF
bv.plotf(F, in3d=TRUE, …, xlim, ylim)########################################
#binomial
########################################
# S3 method for BNBVPMF
bv.plotf(f, in3d=TRUE, …, xlim, ylim, all=FALSE)
# S3 method for BNBVCDF
bv.plotf(F, in3d=TRUE, …, xlim, ylim)
########################################
#poisson
########################################
# S3 method for PBVPMF
bv.plotf(f, in3d=TRUE, …, xlim, ylim, all=FALSE)
# S3 method for PBVCDF
bv.plotf(F, in3d=TRUE, …, xlim, ylim)
########################################
#continuous uniform
########################################
# S3 method for CUBVPDF
bv.plotf(f, in3d=TRUE, …, all=FALSE, n=20)
# S3 method for CUBVCDF
bv.plotf(F, in3d=TRUE, …, n=20)
########################################
#normal
#(bivariate and trivariate)
########################################
# S3 method for NBVPDF
bv.plotf(f, in3d=TRUE, …, xlim, ylim, all=FALSE, n=30)
# S3 method for NBVCDF
bv.plotf(F, in3d=TRUE, …, xlim, ylim, n=30)
# S3 method for NTVPDF
bv.plotf(f, iso=TRUE, …, xlim, ylim, zlim)
########################################
#bimodal
########################################
# S3 method for BMBVPDF
bv.plotf(f, in3d=TRUE, …, xlim, ylim, all=FALSE, n=40)
# S3 method for BMBVCDF
bv.plotf(F, in3d=TRUE, …, xlim, ylim, n=40)
########################################
#categorical, dirichlet, kernel, ecdf
########################################
# S3 method for GBVPMF
bv.plotf(f, in3d=TRUE, data, …)
# S3 method for DTVPDF
bv.plotf(f, in3d=TRUE, …, log=FALSE, n=30)
# S3 method for KBVPDF
bv.plotf(fh, in3d=TRUE, data = (fh@n <= 2000),="" …,="" xlim,="" ylim,="" n="30," point.color="#00000030" )<="" p="">
# S3 method for EBVCDF
bv.plotf(Fh, in3d=TRUE, …, reg = (Fh@n > 40) )
########################################
#additional plotting functions
#(called by the ebvcdf method, above)
########################################
ebvcdf_plot_reg (Fh, in3d=TRUE, …, xlim, ylim, n=30)
ebvcdf_plot_step_2d (Fh, data=TRUE, steps=data, …,
point.color="#00000030", line.color="#000000", border.color="#808080",
main.colff = st.litmus.fit (theme), rim.colff=rim.litmus.fit,
theme)
ebvcdf_plot_step_3d (Fh, …,
top.color = st.top.color (theme), side.color = st.side.color (theme),
rim.color="#D0D0D0",
theme)
=>
A function representing a PMF/PDF or CDF, from this package. Refer to the see also section.
Logical value, if true, a 3d plot, if false, a 2d plot.
The x, y and z ranges for the plot.
Logical value, if true, plot a two by two array of both the PMF/PDF and CDF using both 2d and 3d plots. Note that by default, ref.arrows (reference arrows in 3d plots) will be true, regardless of global options. And some plotting arguments are ignored.
Integer vector of length one or two, the number of grid bins/points in each x and y direction. (Except for Dirichlet distributions, where it needs to be scalar). Note that, n, is also an attribute of kbvpdf and ebvcdf objects, representing sample size.
Logical value, if true, plot isosurfaces.
Logical value, if true, plot the log density.
Logical value, if true, plot the probability distribution as a continuous surface, evaluated over a regularly-spaced grid. (Refer to details).
Logical value, if true, plot the data points/labels. Ignored, if in3d is true.
Logical value, if true, plot the steps.
String, the color for points, lines and borders.
Strings, giving the bar top, bar side and rim bar colors.
Litmus-fitting functions. Refer to the barsurf package. Note that the default for rim.colff is rim.litmus.fit, which is defined in this package.
Refer to barsurf package.
Other arguments for plotting functions in the barsurf package. Refer to the details section.
You can use the standard plot function. i.e. Calling plot will call the bv.plotf function.
GENERAL INFORMATION
These functions call functions in the barsurf package:
2d plotting functions call plot_dfield, plot_cfield or plot_tricontour. (The categorical method, calls plot_matrix, which calls plot_dfield).
3d plotting functions call plot_bar, plot_surface or plot_trisurface. Except for the trivariate normal method, which calls plotf_isosurface or plotf_cfield3.
Re-iterating, the misc3d package needs to be installed and loaded, in order to plot the trivariate normal distribution.
The barsurf package is built on top of the base graphics system, but uses a different color system. You will need to refer to the documentation for that package to change surface and heatmap colors.
DEFAULTS
As of bivariate version 0.6.0, 3d plots are the default.
By default, 3d plots use reference arrows. (This can be changed by first calling set.bs.options with ref.arrows=FALSE).
By default, 3d PMFs/PDFs have no z axis markup, but 3d CDFs do. (This can be changed by setting the z.axis argument to true or false).
By default, 3d PMFs/PDFs have zlim equal to c (0, zmax). And by default, 3d CDFs have zlim equal to c (0, 1).
Where in general, zmax will be the maximum value of the PMF/PDF, within the evaluation window. Exceptions include uniform distributions (which use zero to one, if the maximum function value is less than or equal to one) and Dirichlet distributions (which vertically center the surface, if all alpha parameters are equal to one).
By default, 2d PMFs/PDFs have unlabelled contour lines, and 2d CDFs have labelled contour lines at 0.2, 0.4, 0.6 and 0.8. (The ncontours, contour.labels, fb and clabs arguments, can be used to change this).
CATEGORICAL DISTRIBUTIONS
Note that the 2d plot has a different orientation to other 2d plots in this package.
For optimal results, you should update the plot margins, before and after the calling the plot method. (This can be done, using the matrix.margins function, from the barsurf package).
EMPIRICAL CUMULATIVE DISTRIBUTION FUNCTIONS
The plot method for ebvcdf objects calls either plot_ebvcdf_reg, plot_ebvcdf_step_2d or plot_ebvcdf_step_3d, depending on the in3d and reg arguments.
The plot_ebvcdf_step_2d and plot_ebvcdf_step_3d functions plot the ECDF as a step function. (This could be regarded as an exact representation).
The plot_ebvcdf_reg function plots the ECDF as a continuous surface, evaluated over a regularly-spaced grid. (This could be regarded as an approximation).
Note that setting reg=FALSE for large sample sizes, is probably a bad idea. (But the continuous approximation improves as the sample size increases).
Refer to the vignette for an overview, references, theoretical background and better examples.
Uniform For uniform distributions.
Binomial, Poisson and Categorical For other probability distributions of discrete random variables.
Normal, Bimodal, Dirichlet and Nonparametric For other probability distributions of continuous random variables.
# NOT RUN {
########################################
#PDF
########################################
f <- nbvpdf ()
plot (f)
plot (f, z.axis=TRUE, ref.arrows=FALSE)
plot (f, grid=FALSE, n=60)
plot (f, FALSE)
plot (f, FALSE, hcv=TRUE)
########################################
#CDF
########################################
F <- nbvcdf ()
plot (F)
plot (F, FALSE)
plot (F, FALSE, fb=0.5)
tempff <- function (x)
barsurf::hot.and.cold.fit (x, t = c (0.45, 0.55) )
plot (F, gradient.shading=FALSE, colff=tempff, n=60)
# }
Run the code above in your browser using DataLab