Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions R/vis-dat.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ vis_dat <- function(
# change the limits etc.
ggplot2::guides(fill = ggplot2::guide_legend(title = "Type")) +
# add info about the axes
ggplot2::scale_x_discrete(limits = col_order_index, position = "top") +
ggplot2::theme(axis.text.x = ggplot2::element_text(hjust = 0))
ggplot2::scale_x_discrete(limits = col_order_index, position = "top")

if (!missing(facet)) {
vis_dat_plot <- vis_dat_plot +
Expand Down
18 changes: 9 additions & 9 deletions R/vis-expect.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ vis_expect <- function(data, expectation, show_perc = TRUE) {
ggplot2::ggplot(ggplot2::aes(x = variable, y = rows)) +
ggplot2::geom_raster(ggplot2::aes(fill = valueType)) +
ggplot2::theme_minimal() +
ggplot2::theme(
axis.text.x = ggplot2::element_text(angle = 45, vjust = 1, hjust = 1)
) +
ggplot2::labs(x = "", y = "Observations") +
# flip the axes
ggplot2::scale_y_reverse() +
Expand All @@ -110,15 +107,18 @@ vis_expect <- function(data, expectation, show_perc = TRUE) {
"grey"
),
labels = c(p_expect_false_lab, p_expect_true_lab),
# light gray
na.value = "#E5E5E5"
) + # light gray
ggplot2::guides(fill = ggplot2::guide_legend(reverse = TRUE)) +
) +
# change the limits etc.
ggplot2::guides(fill = ggplot2::guide_legend(title = "Expectation")) +
ggplot2::guides(
fill = ggplot2::guide_legend(
title = "Expectation",
reverse = TRUE
)
) +
# add info about the axes
ggplot2::theme(legend.position = "bottom") +
# ggplot2::theme(axis.text.x = ggplot2::element_text(hjust = 0.5)) +
ggplot2::theme(axis.text.x = ggplot2::element_text(hjust = 0))
ggplot2::theme_sub_legend(position = "bottom")

vis_expect_plot
}
Expand Down
3 changes: 1 addition & 2 deletions R/vis-guess.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ vis_guess <- function(x, palette = "default") {
vis_plot <- vis_create_(d) +
ggplot2::guides(fill = ggplot2::guide_legend(title = "Type")) +
# flip the axes, add info for axes
ggplot2::scale_x_discrete(position = "top", limits = names(x)) +
ggplot2::theme(axis.text.x = ggplot2::element_text(hjust = 0))
ggplot2::scale_x_discrete(position = "top", limits = names(x))

# specify a palette ----------------------------------------------------------
add_vis_dat_pal(vis_plot, palette)
Expand Down
4 changes: 2 additions & 2 deletions R/vis-histogram.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ vis_histogram_create <- function(data, ...) {
ggplot2::theme_minimal() +
ggplot2::labs(x = "", y = "") +
ggplot2::guides(fill = ggplot2::guide_legend(title = "Histogram")) +
ggplot2::theme(
axis.text.x = ggplot2::element_text(angle = 45, hjust = 0.1)
ggplot2::theme_sub_axis_x(
text = ggplot2::element_text(angle = 45, hjust = 0.1)
)
}
55 changes: 26 additions & 29 deletions R/vis-miss.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,37 +140,34 @@ vis_miss <- function(
)
) +
ggplot2::guides(fill = ggplot2::guide_legend(reverse = TRUE)) +
ggplot2::theme(legend.position = "bottom") +
# fix up the location of the text
ggplot2::theme(axis.text.x = ggplot2::element_text(hjust = 0))

# add the missingness column labels

# if there is only one colummn you don't need to sort the columns
# this is perhaps a bit of a hacky way around, but I can't see another
# way around it. Related issue: https://github.com/ropensci/visdat/issues/72
if (ncol(x) == 1) {
if (show_perc_col) {
return(
vis_miss_plot <- vis_miss_plot +
ggplot2::scale_x_discrete(
position = "top",
labels = label_col_missing_pct(
x_fingerprinted,
col_order_index
ggplot2::theme_sub_legend(position = "bottom") +
# add the missingness column labels

# if there is only one colummn you don't need to sort the columns
# this is perhaps a bit of a hacky way around, but I can't see another
# way around it. Related issue: https://github.com/ropensci/visdat/issues/72
if (ncol(x) == 1) {
if (show_perc_col) {
return(
vis_miss_plot <- vis_miss_plot +
ggplot2::scale_x_discrete(
position = "top",
labels = label_col_missing_pct(
x_fingerprinted,
col_order_index
)
)
)
)
} else if (!show_perc_col) {
return(
vis_miss_plot <- vis_miss_plot +
ggplot2::scale_x_discrete(
position = "top",
labels = col_order_index
)
)
)
} else if (!show_perc_col) {
return(
vis_miss_plot <- vis_miss_plot +
ggplot2::scale_x_discrete(
position = "top",
labels = col_order_index
)
)
}
}
}

if (!missing(facet)) {
vis_miss_plot <- vis_miss_plot +
Expand Down
1 change: 0 additions & 1 deletion R/vis-value.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,5 @@ vis_value <- function(data, na_colour = "grey90", viridis_option = "D") {
ggplot2::guides(fill = ggplot2::guide_legend(title = "Value")) +
# add info about the axes
ggplot2::scale_x_discrete(position = "top") +
ggplot2::theme(axis.text.x = ggplot2::element_text(hjust = 0)) +
ggplot2::scale_fill_viridis_c(option = viridis_option, na.value = na_colour)
}
Loading