Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
90 changes: 27 additions & 63 deletions R/jaspPlotBuilder.R
Original file line number Diff line number Diff line change
Expand Up @@ -1478,7 +1478,9 @@ addDecodedLabels <- function(p) {
tidyplot_obj <- layer_calls[[lay]](tidyplot_obj)
}

if (length(tab[["titlePlotBuilder"]]) > 0) {
if (!is.null(tab[["titlePlotBuilder"]]) &&
length(tab[["titlePlotBuilder"]]) > 0 &&
nchar(trimws(tab[["titlePlotBuilder"]])) > 0) {
tidyplot_obj <- tidyplot_obj |>
tidyplots::add_title(title = tab[["titlePlotBuilder"]])
}
Expand Down Expand Up @@ -1532,7 +1534,7 @@ addDecodedLabels <- function(p) {
tidyplot_obj <- gg
}

#Point shape by variable ----
#Point shape by variable ----
if (!is.null(shapeVar) && shapeVar %in% colnames(localData)) {

if (length(unique(localData[[shapeVar]])) > 1) {
Expand Down Expand Up @@ -1782,90 +1784,51 @@ addDecodedLabels <- function(p) {
}

# Adjust Y axis (tidyplots::adjust_y_axis)----



{
adjust_args_yaxis <- list()

titleValueY <- tab[["titleYPlotBuilder"]]
if (!is.null(titleValueY) && titleValueY != "") {
adjust_args_yaxis$title <- titleValueY
}

# --- Limit beállítások ---
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use English for comments/ variable names.

Copy link
Contributor Author

@matyasbukva matyasbukva Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't deal with this this week because I'm on a short vacation . But feel free to delete this comment anyway.

limitFromY <- suppressWarnings(as.numeric(tab[["limitFromY"]]))
limitToY <- suppressWarnings(as.numeric(tab[["limitToY"]]))
fromValueY <- suppressWarnings(as.numeric(tab[["breakFromY"]]))
toValueY <- suppressWarnings(as.numeric(tab[["breakToY"]]))
byValueY <- suppressWarnings(as.numeric(tab[["breakByY"]]))
user_has_limits <- !is.na(limitFromY) && !is.na(limitToY)
user_has_breaks <- !is.na(fromValueY) && !is.na(toValueY) && !is.na(byValueY)


automatic_limit_setting_active <- TRUE

if (user_has_limits) {
adjust_args_yaxis$limits <- c(limitFromY, limitToY)
automatic_limit_setting_active <- FALSE
}

if (automatic_limit_setting_active) {

highest_y_from_annots <- -Inf
num_comparisons <- 0
if (!is.null(tab[["pairwiseComparisons"]])) {
num_comparisons <- length(tab[["pairwiseComparisons"]])
}

if (num_comparisons > 0 && !is.null(tab[["yPositionPValue"]])) {
y_pos_base <- suppressWarnings(as.numeric(tab[["yPositionPValue"]]))
step_inc <- suppressWarnings(as.numeric(tab[["stepDistance"]]))
if (is.na(step_inc)) step_inc <- 0

if (is.finite(y_pos_base)) {
highest_y_from_annots <- y_pos_base + (num_comparisons - 1) * step_inc
}
}

max_y_from_data <- -Inf
if (!is.null(yVar) && yVar %in% colnames(localData) && is.numeric(localData[[yVar]])) {
max_y_from_data <- max(localData[[yVar]], na.rm = TRUE)
}

required_y_max <- max(max_y_from_data, highest_y_from_annots, na.rm = TRUE)

if (is.finite(required_y_max)) {
min_y <- min(localData[[yVar]], na.rm = TRUE)
adjust_args_yaxis$limits <- c(min_y, required_y_max * 1.05)
}
}
# --- Breaks beállítása ---
fromValueY <- suppressWarnings(as.numeric(tab[["breakFromY"]]))
toValueY <- suppressWarnings(as.numeric(tab[["breakToY"]]))
byValueY <- suppressWarnings(as.numeric(tab[["breakByY"]]))
user_has_breaks <- !is.na(fromValueY) && !is.na(toValueY) && !is.na(byValueY)

if (user_has_breaks) {
adjust_args_yaxis$breaks <- seq(fromValueY, toValueY, byValueY)
}

num_comparisons_for_padding <- 0
if (!is.null(tab[["pairwiseComparisons"]])) {
num_comparisons_for_padding <- length(tab[["pairwiseComparisons"]])
}

# --- Padding beállítása ---
bottom_padding <- suppressWarnings(as.numeric(tab[["YPaddingFirst"]]))
top_padding <- suppressWarnings(as.numeric(tab[["YPaddingSecond"]]))

if (num_comparisons_for_padding > 1) {
additional_padding <- (num_comparisons_for_padding - 1) * 0.15
top_padding <- top_padding + additional_padding
if (is.finite(bottom_padding) || is.finite(top_padding)) {
adjust_args_yaxis$padding <- c(
ifelse(is.finite(bottom_padding), bottom_padding, 0.05),
ifelse(is.finite(top_padding), top_padding, 0.05)
)
}

adjust_args_yaxis$padding <- c(bottom_padding, top_padding)

adjust_args_yaxis$rotate_labels <- isTRUE(tab[["rotateYLabel"]])
adjust_args_yaxis$cut_short_scale <- isTRUE(tab[["cutShortScaleY"]])

# --- Tengely beállítása ---
if (length(adjust_args_yaxis) > 0) {
tidyplot_obj <- do.call(
tidyplots::adjust_y_axis,
c(list(tidyplot_obj), adjust_args_yaxis)
)
}

# --- Opcionális Y-tengelyrendezés ---
enableSortY <- tab[["enableSortY"]]
if (isTRUE(enableSortY)) {
sortOrderY <- tab[["sortYLabelsOrder"]]
Expand All @@ -1884,6 +1847,7 @@ addDecodedLabels <- function(p) {
}



# Adjust Y axis labels (tidyplots::rename_y_axis_labels)----
if (!is.null(tab[["yAxisLabelRenamer"]]) && length(tab[["yAxisLabelRenamer"]]) > 0) {
# Filter for entries where both original and new labels are non-empty and not null
Expand Down Expand Up @@ -2323,12 +2287,12 @@ addDecodedLabels <- function(p) {
stringsAsFactors = FALSE
)

rmOption <- tab[["isRM"]]
rmOption <- tab[["isRM"]]

if (rmOption == "RM") {
dfComparisons$group1 <- encodeColNames(dfComparisons$group1)
dfComparisons$group2 <- encodeColNames(dfComparisons$group2)
}
if (rmOption == "RM") {
dfComparisons$group1 <- encodeColNames(dfComparisons$group1)
dfComparisons$group2 <- encodeColNames(dfComparisons$group2)
}

if (!is.null(colorVar)) {
dfComparisons$color <- as.character(
Expand Down
8 changes: 4 additions & 4 deletions inst/qml/jaspPlotBuilder.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2806,10 +2806,10 @@ TabView {
info: qsTr("Fraction of the data range to leave empty inside each axis (0 – 1)")
columns: 4

DoubleField { name: "YPaddingSecond"; label: qsTr("Top"); value: 0.05 }
DoubleField { name: "YPaddingFirst"; label: qsTr("Bottom"); value: 0.04 }
DoubleField { name: "XPaddingFirst"; label: qsTr("Left"); value: 0.05 }
DoubleField { name: "XPaddingSecond"; label: qsTr("Right"); value: 0.05 }
DoubleField { name: "YPaddingSecond"; label: qsTr("Top"); value: 0.1 }
DoubleField { name: "YPaddingFirst"; label: qsTr("Bottom"); value: 0.1 }
DoubleField { name: "XPaddingFirst"; label: qsTr("Left"); value: 0.1 }
DoubleField { name: "XPaddingSecond"; label: qsTr("Right"); value: 0.1 }
}

Group {
Expand Down
Loading