diff --git a/R/aaa.R b/R/aaa.R index 598ad7f..9a25a83 100644 --- a/R/aaa.R +++ b/R/aaa.R @@ -27,3 +27,4 @@ state_coords <- structure(list(abbrev = c("AL", "AK", "AZ", "AR", "CA", "CO", .Names = c("abbrev", "state", "col", "row"), class = "data.frame", row.names = c(NA, -54L)) +state_coords <- state_coords[order(state_coords$state),] \ No newline at end of file diff --git a/R/statebins-manual.R b/R/statebins-manual.R index ee64a38..ef8be0c 100644 --- a/R/statebins-manual.R +++ b/R/statebins-manual.R @@ -79,11 +79,12 @@ statebins_manual <- function(state_data, state_col="state", color_col="color", st.dat <- merge(state_coords, state_data, by.x=merge.x, by.y=state_col, all.y=TRUE) gg <- ggplot(st.dat, aes_string(x="col", y="row", label="abbrev")) - gg <- gg + geom_tile(aes_string(fill="color")) + gg <- gg + geom_tile(aes_string(fill=color_col)) gg <- gg + geom_tile(color=state_border_col, aes_string(fill="color"), size=2, show.legend=FALSE) gg <- gg + geom_text(color=text_color, size=font_size) gg <- gg + scale_y_reverse() + if (is.null(labels)) { gg <- gg + scale_fill_manual(values=unique(st.dat[,color_col])) legend_position = "none" @@ -91,6 +92,7 @@ statebins_manual <- function(state_data, state_col="state", color_col="color", gg <- gg + scale_fill_manual(values=unique(st.dat[,color_col]), labels=labels, name=legend_title) } + gg <- gg + coord_equal() gg <- gg + labs(x=NULL, y=NULL, title=NULL) gg <- gg + theme_bw() diff --git a/R/statebins.R b/R/statebins.R index f44a614..57f9283 100644 --- a/R/statebins.R +++ b/R/statebins.R @@ -66,9 +66,9 @@ statebins <- function(state_data, state_col="state", value_col="value", palette <- match.arg(trimws(tolower(palette)), c("brewer", "viridis")) - if (breaks <= 0 | breaks > 10) { - stop("'breaks' must be between 0 & 10") - } + # if (breaks <= 0 | breaks > 10) { + # stop("'breaks' must be between 0 & 10") + # } if (!title_position %in% c("", "top", "bottom")) { stop("'title_position' must be either blank, 'top' or 'bottom'")