Skip to content

Commit 0050da5

Browse files
committed
Note/warning free!
1 parent 6abe237 commit 0050da5

File tree

9 files changed

+81
-41
lines changed

9 files changed

+81
-41
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
S3method(gsplot,list)
44
S3method(print,gsplot)
55
export("%>%")
6+
export(abline)
67
export(axis)
78
export(calc_views)
89
export(gsplot)

R/abline.R

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,14 @@
77
#' @param object gsplot object
88
#' @param \dots Further graphical parameters may also be supplied as arguments. See 'Details'.
99
#' @return modified gsplot object
10-
#' @rdname points
11-
#' @examples
12-
#' gsNew <- gsplot(list())
13-
#' gsNew <- points(gsNew, y=1, x=2, col="blue", pch=18)
14-
#' gsNew <- points(gsNew, c(3,4,3), c(2,4,6))
15-
#' gsNew <- abline(gsNew, v=3, lty=1)
16-
#' gsNew
1710
#' @export
1811
abline <- function(object, ...) {
1912
overrideGraphics("abline", object, ...)
2013
}
2114

2215

2316
abline.gsplot <- function(object, x, y=NULL, ..., legend.name=NULL, side=c(1,2)){
24-
current_list <- config("grid")
17+
current_list <- config("abline")
2518
arguments <- list(x=x, y=y, ...)
2619

2720
indicesToAdd <- !(names(current_list) %in% names(arguments))

R/calc_views.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1+
#' calc_view
2+
#'
3+
#' calc_view
4+
#'
5+
#'
6+
#' @param gsplot object
17
#' @export
8+
#' @keywords internal
29
calc_views <- function(gsplot){
310

411
views <- group_views(gsplot)

R/legend.R

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#' lines(x=c(3,4,3), y=c(2,4,6), legend.name="Example Lines", lty=5, col="orange") %>%
1919
#' points(x=1, y=2, side=c(3,2), legend.name="Example Points 1", pch=1, col="blue") %>%
2020
#' points(x=3, y=4, side=c(1,4), legend.name="Example Points 2", pch=5, col="red") %>%
21-
#' legend(location="topright")
21+
#' legend(location="topright", title="LEGEND!!!")
2222
#' topright
2323
#'
2424
#' defaultLegend <- gsplot(list()) %>%
@@ -152,38 +152,41 @@ draw_legend <- function(gsplot) {
152152

153153
smartLegend <- unique(smartLegend)
154154

155-
#only include pch if we have a non-NA entry for points
156-
if(length(pts_i) > 0) {
157-
legendParams <- append(legendParams, list(
158-
pch=smartLegend$symbol
159-
))
160-
}
161-
162-
#only include lty if we have a non-NA entry for lines
163-
if(length(lines_i) > 0) {
164-
legendParams <- append(legendParams, list(
165-
lty=smartLegend$line
166-
))
167-
}
155+
if(nrow(smartLegend) > 0){
168156

169-
legendParams <- append(legendParams, list(
170-
legend=smartLegend$text,
171-
col=smartLegend$color
172-
))
173-
174-
#for above/below, dynamically set the number of columns
175-
location <- gsplot[['legend']][['gs.config']][['location']]
176-
if(location == "below" || location == "above") {
177-
itemsPerCol <- 3 #TODO load this from config
178-
cols <- NROW(smartLegend) %/% 3;
179-
if(NROW(smartLegend) %% 3 > 0) {
180-
cols <- cols + 1
157+
#only include pch if we have a non-NA entry for points
158+
if(length(pts_i) > 0) {
159+
legendParams <- append(legendParams, list(
160+
pch=smartLegend$symbol
161+
))
162+
}
163+
164+
#only include lty if we have a non-NA entry for lines
165+
if(length(lines_i) > 0) {
166+
legendParams <- append(legendParams, list(
167+
lty=smartLegend$line
168+
))
181169
}
170+
182171
legendParams <- append(legendParams, list(
183-
ncol=cols
172+
legend=smartLegend$text,
173+
col=smartLegend$color
184174
))
175+
176+
#for above/below, dynamically set the number of columns
177+
location <- gsplot[['legend']][['gs.config']][['location']]
178+
if(location == "below" || location == "above") {
179+
itemsPerCol <- 3 #TODO load this from config
180+
cols <- NROW(smartLegend) %/% 3;
181+
if(NROW(smartLegend) %% 3 > 0) {
182+
cols <- cols + 1
183+
}
184+
legendParams <- append(legendParams, list(
185+
ncol=cols
186+
))
187+
}
188+
legend(legendParams)
185189
}
186-
legend(legendParams)
187190
}
188191
}
189192

R/points.R

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
#' gsplot points
22
#'
33
#' Point stuff
4-
#' @usage
5-
#' points(object, legend.name=NULL, side=c(1,2), ...)
64
#'
75
#' @details Add additional functionality to points.
86
#'
97
#' @param object gsplot object
108
#' @param \dots Further graphical parameters may also be supplied as arguments. See 'Details'.
119
#' @return modified gsplot object
12-
#' @rdname points
1310
#' @examples
1411
#' gs <- gsplot(list())
1512
#' gsNew <- points(gs, y=1, x=2, col="blue", pch=18)

man/abline.Rd

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
% Generated by roxygen2 (4.1.1): do not edit by hand
2+
% Please edit documentation in R/abline.R
3+
\name{abline}
4+
\alias{abline}
5+
\title{gsplot abline}
6+
\usage{
7+
abline(object, ...)
8+
}
9+
\arguments{
10+
\item{object}{gsplot object}
11+
12+
\item{\dots}{Further graphical parameters may also be supplied as arguments. See 'Details'.}
13+
}
14+
\value{
15+
modified gsplot object
16+
}
17+
\description{
18+
abline stuff
19+
}
20+
\details{
21+
Add additional functionality to points.
22+
}
23+

man/calc_views.Rd

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
% Generated by roxygen2 (4.1.1): do not edit by hand
2+
% Please edit documentation in R/calc_views.R
3+
\name{calc_views}
4+
\alias{calc_views}
5+
\title{calc_view}
6+
\usage{
7+
calc_views(gsplot)
8+
}
9+
\arguments{
10+
\item{gsplot}{object}
11+
}
12+
\description{
13+
calc_view
14+
}
15+
\keyword{internal}
16+

man/legend.Rd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ topright <- gsplot(list()) \%>\%
2929
lines(x=c(3,4,3), y=c(2,4,6), legend.name="Example Lines", lty=5, col="orange") \%>\%
3030
points(x=1, y=2, side=c(3,2), legend.name="Example Points 1", pch=1, col="blue") \%>\%
3131
points(x=3, y=4, side=c(1,4), legend.name="Example Points 2", pch=5, col="red") \%>\%
32-
legend(location="topright")
32+
legend(location="topright", title="LEGEND!!!")
3333
topright
3434

3535
defaultLegend <- gsplot(list()) \%>\%

man/points.Rd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
\alias{points}
55
\title{gsplot points}
66
\usage{
7-
points(object, legend.name=NULL, side=c(1,2), ...)
7+
points(object, ...)
88
}
99
\arguments{
1010
\item{object}{gsplot object}

0 commit comments

Comments
 (0)