Last data update: 2014.03.03

R: Function producing enhanced XY plots
xy.plotR Documentation

Function producing enhanced XY plots

Description

xy.plot produces xyplots and provides coverage and consistency values. The advantage over fsplot() (in the QCA3 package) is its larger flexibility and that it does not need a dataset to work, it just need two vectors. Several graphic parameters can be decided by the user.

Usage

xy.plot(x, y, 
        ylim = c(-0.05, 1.05), xlim = c(-0.05, 1.05), 
        pch = 19, col = "black", main = "XY plot", 
        ylab = "Outcome", xlab = "Condition", 
        mar = c(4, 4, 4, 1), mgp = c(2.2, 0.8, 0), 
        cex.fit = 0.6, cex.axis = 0.7, cex.main = 1, 
        necessity = FALSE, show.hv = TRUE, show.fit = TRUE, 
        pos.fit = "top", case.lab = TRUE, labs = NULL, 
        cex.lab = 0.8, offset.x = 0, offset.y = 0, 
        pos = 4, srt = 0, 
        ident = FALSE)

Arguments

x

vector containing the condition.

y

vector containing the outcome.

ylim

limits of y-axis. The default is c(-0.05, 1.05).

xlim

limits of x-axis. The default is c(-0.05, 1.05).

pch

plotting "character". The default is 19. See ?pch.

col

color for the plotting "character". The default is "black". See ?par.

main

an overall title for the plot. The default is "XY plot". See ?title.

ylab

a title for the y-axis. The default is "Outcome". See ?title.

xlab

a title for the x-axis. The default is "Condition". See ?title.

mar

A numerical vector of the form c(bottom, left, top, right) which gives the number of lines of margin to be specified on the four sides of the plot. The default is c(4, 4, 4, 1). See ?par.

mgp

The margin line (in mex units) for the axis title, axis labels and axis line. Note that mgp[1] affects title whereas mgp[2:3] affect axis. The default is c(2.2, 0.8, 0). See ?par.

cex.fit

character expansion for the parameters of fit. The defaut is 0.6. See ?pch or ?text.

cex.axis

character expansion for the x-axis and y-axis. The defaut is 0.7. See ?pch or ?text.

cex.main

character expansion for the overall title of the plot. The defaut is 1. See ?pch or ?text.

necessity

logical. Indicates if the parameters of fit are calculated for a sufficient or necessary condition. The default is FALSE, therefore it calculates the parameters of fit for sufficiency. To get the parameters of fit for necessary conditions set necessity as TRUE.

show.hv

logical. Indicates if horizontal and vertical lines at 0.5 have to be shown. The default is TRUE.

show.fit

logical. Indicates if parameters of fit have to be shown. The default is TRUE.

pos.fit

character. Indicates the position of the parameters of fit. The positions are "top", which places the parameters of fit outsite the plotting are just below the main title, or "corner", which places the parameters of fit in the corner of the plotting are. The default is pos.fit = "top".

case.lab

logical. Indicates if cases have to be labeled. The default is TRUE.

labs

the vector of case labels. The default is NULL.

cex.lab

character expansion for case labels. The default is 0.8.

offset.x

is a numerical value that sets the offset for case labels position on the x-axis. The default is 0.

offset.y

is a numerical value that sets the offset for case labels position on the y-axis. The default is 0.

pos

a position specifier for the case labels. Values of 1, 2, 3 and 4, respectively indicate positions below, to the left of, above and to the right of the specified coordinates. The default is 4. See ?text.

srt

indicates the rotation of the case labels in degrees. The default is 0. See ?par.

ident

logical. Indicates if identify() has to be used to label the cases. When set to TRUE case.lab has to be FALSE and labels have to be provided by the user. The defaults is FALSE. See ?identify.

Value

It returns an enhanced XY plot.

Author(s)

Mario Quaranta.

References

Ragin, C. C. (2008) Redesigning Social Inquiry: Fuzzy Sets and Beyond. The Chicago University Press: Chicago and London.

Schneider, C. Q., Wagemann, C. (2012) Set-Theoretic Methods for the Social Sciences, Cambridge Univeristy Press: Cambridge.

Schneider, C. Q., Wagemann, C., Quaranta, M. (2012) How To... Use Software for Set-Theoretic Analysis. Online Appendix to "Set-Theoretic Methods for the Social Sciences". Available at www.cambridge.org/schneider-wagemann

Examples

# Generate fake data
set.seed(123)
x <- runif(40, 0, 1)
y <- runif(40, 0, 1)

# Default
xy.plot(x, y)

# With labels
xy.plot(x, y, case.lab = TRUE, labs = 1:40)

# With labels and bigger measures of fit
xy.plot(x, y, case.lab = TRUE, labs = 1:40, cex.fit = 1)

# With labels and bigger title
xy.plot(x, y, case.lab = TRUE, labs = 1:40, cex.main = 1.5)

# Generate fake data the have perfect sufficiency
set.seed(123)
x <- runif(50, 0, 1)
y <- runif(50, 0, 1)

for(i in 1:length(y)) {
    while(x[i] > y[i]) {
        y[i] <- runif(1, 0, 1)
        x[i] <- runif(1, 0, 1)
    }
}

# Default
xy.plot(x, y)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(SetMethods)
Loading required package: lattice
Loading required package: betareg
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/SetMethods/xy.plot.Rd_%03d_medium.png", width=480, height=480)
> ### Name: xy.plot
> ### Title: Function producing enhanced XY plots
> ### Aliases: xy.plot
> 
> ### ** Examples
> 
> # Generate fake data
> set.seed(123)
> x <- runif(40, 0, 1)
> y <- runif(40, 0, 1)
> 
> # Default
> xy.plot(x, y)
> 
> # With labels
> xy.plot(x, y, case.lab = TRUE, labs = 1:40)
> 
> # With labels and bigger measures of fit
> xy.plot(x, y, case.lab = TRUE, labs = 1:40, cex.fit = 1)
> 
> # With labels and bigger title
> xy.plot(x, y, case.lab = TRUE, labs = 1:40, cex.main = 1.5)
> 
> # Generate fake data the have perfect sufficiency
> set.seed(123)
> x <- runif(50, 0, 1)
> y <- runif(50, 0, 1)
> 
> for(i in 1:length(y)) {
+     while(x[i] > y[i]) {
+         y[i] <- runif(1, 0, 1)
+         x[i] <- runif(1, 0, 1)
+     }
+ }
> 
> # Default
> xy.plot(x, y)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>