Skip to content

Commit 2320526

Browse files
committedMar 10, 2016
reinstitute plotting of lists
While updating line calculation code the lapply wrapper in circleplot() was removed, withdrawing capacity to plot multiple objects stored in lists. This has been re-added in the current version. Functions make.wide.format and make.long.format no longer available to user, but are given in sppairs [devtools::install_github(‘mjwestgate/sppairs)].
1 parent 6048cb0 commit 2320526

File tree

5 files changed

+45
-38
lines changed

5 files changed

+45
-38
lines changed
 

‎DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: circleplot
2-
Version: 0.4
2+
Version: 0.4.1
33
Date: 2016-02-03
44
Title: Circular plots of distance and association matrices
55
Author: Martin J. Westgate <martinjwestgate@gmail.com>

‎INDEX

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
circleplot Draw a plot
22
draw.circle Add a circle to an existing plot
33
make.circle Return a set of points on the circumference of a circle
4-
make.long.format Convert a matrix to a data.frame
5-
make.wide.format Convert a data.frame to a matrix
64
point.attr Generate point colours

‎NAMESPACE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export(circleplot, draw.circle, make.circle, make.long.format, make.wide.format, point.attr)
1+
export(circleplot, draw.circle, make.circle, point.attr)

‎R/plot_calls.R

+37-33
Original file line numberDiff line numberDiff line change
@@ -29,40 +29,44 @@ circleplot<-function(
2929
scale.distance<-as.matrix(scale.distance)
3030

3131
# set plot window attributes
32-
if(add==FALSE){
33-
do.call(par, circleplot.object$par)
34-
do.call(plot, circleplot.object$plot)}
3532
if(class(input)=="list")par(mfrow=panel.dims(length(circleplot.object$lines)))
36-
37-
# loop to calculate lines of requisite location and colour
38-
line.data<-circleplot.object$lines[[1]]
39-
line.list<-split(line.data, c(1:nrow(line.data)))
40-
line.list<-lapply(line.list, function(x, plot.object, distance, options){
41-
calc.lines(x, plot.object, distance, options)},
42-
plot.object=circleplot.object, distance=scale.distance, options= plot.options)
43-
44-
# draw these lines
45-
invisible(lapply(line.list,
46-
FUN=function(z, asymmetric, arrow.attr){
47-
draw.curves(z)
48-
if(asymmetric)draw.arrows(z, arrow.attr)},
49-
asymmetric=attr(circleplot.object, "asymmetric"), arrow.attr=plot.options$arrows))
50-
51-
# add points or polygons, depending on style
52-
switch(style,
53-
"classic"={do.call(points,
54-
as.list(circleplot.object$points[, -which(colnames(circleplot.object$points)=="labels")]))},
55-
"pie"={invisible(lapply(circleplot.object$polygons, function(x){do.call(polygon, x)}))},
56-
"clock"={
57-
invisible(lapply(circleplot.object$nodes, function(x){do.call(lines, x)}))
58-
do.call(draw.circle, plot.options$border[-which(names(plot.options$border)=="tcl")])}
59-
)
60-
61-
# label points
62-
label.suppress.test<-is.logical(plot.options$point.labels) & length(plot.options$point.labels)==1
63-
if(label.suppress.test==FALSE){
64-
labels.list<-split(circleplot.object$labels, 1:nrow(circleplot.object$labels))
65-
invisible(lapply(labels.list, FUN=function(x){do.call(text, x)}))}
33+
34+
invisible(lapply(circleplot.object$lines, function(a, add, circleplot.object, scale.distance, plot.options){
35+
if(add==FALSE){
36+
do.call(par, circleplot.object$par)
37+
do.call(plot, circleplot.object$plot)}
38+
39+
# loop to calculate lines of requisite location and colour
40+
# line.data<-circleplot.object$lines[[1]]
41+
line.list<-split(a, c(1:nrow(a)))
42+
line.list<-lapply(line.list, function(x, plot.object, distance, options){
43+
calc.lines(x, plot.object, distance, options)},
44+
plot.object=circleplot.object, distance=scale.distance, options= plot.options)
45+
46+
# draw these lines
47+
invisible(lapply(line.list,
48+
FUN=function(z, asymmetric, arrow.attr){
49+
draw.curves(z)
50+
if(asymmetric)draw.arrows(z, arrow.attr)},
51+
asymmetric=attr(circleplot.object, "asymmetric"), arrow.attr=plot.options$arrows))
52+
53+
# add points or polygons, depending on style
54+
switch(style,
55+
"classic"={do.call(points,
56+
as.list(circleplot.object$points[, -which(colnames(circleplot.object$points)=="labels")]))},
57+
"pie"={invisible(lapply(circleplot.object$polygons, function(x){do.call(polygon, x)}))},
58+
"clock"={
59+
invisible(lapply(circleplot.object$nodes, function(x){do.call(lines, x)}))
60+
do.call(draw.circle, plot.options$border[-which(names(plot.options$border)=="tcl")])}
61+
)
62+
63+
# label points
64+
label.suppress.test<-is.logical(plot.options$point.labels) & length(plot.options$point.labels)==1
65+
if(label.suppress.test==FALSE){
66+
labels.list<-split(circleplot.object$labels, 1:nrow(circleplot.object$labels))
67+
invisible(lapply(labels.list, FUN=function(x){do.call(text, x)}))}
68+
69+
}, add=add, circleplot.object= circleplot.object, scale.distance= scale.distance, plot.options= plot.options))
6670

6771
if(class(input)=="list")par(mfrow=c(1, 1))
6872

‎R/prep_objects.R

+6-1
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,12 @@ calc.circleplot<-function(x, plot.options, cluster, style){
446446
# get information on points and labels, but do not add x,y coordinates
447447
point.dframe<-plot.options$points
448448
point.dframe$order.auto<-new.order
449-
label.dframe<-plot.options$point.labels
449+
if(class(plot.options$point.labels)=="logical"){
450+
if(length(plot.options$point.labels)==1){
451+
label.dframe<-point.dframe
452+
label.dframe$cex<-0}
453+
}else{
454+
label.dframe<-plot.options$point.labels}
450455

451456
# reorder as necessary
452457
if(any(grepl("order", colnames(point.dframe)))){

0 commit comments

Comments
 (0)