Skip to content

Commit

Permalink
Merge pull request ndphillips#231 from hneth/master
Browse files Browse the repository at this point in the history
Fix minor bugs in plotting
  • Loading branch information
hneth authored Sep 4, 2024
2 parents 5e2fc65 + d0615eb commit a04a708
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
11 changes: 10 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,22 @@ From now on, consider using other packages such as **parsnip** or **tidymodels**

## Minor changes

Plotting:

- `plot.FFTrees()` now labels row of 2x2 confusion matrix as "Prediction" when using "test" data.
- `plot.FFTrees()` now has a `truth.labels` argument which, if set, distinguishes labels of true (signal vs. noise) cases from decision outcomes.
- `plot.FFTrees()` now has a `grayscale` argument which, if TRUE, creates a grayscale plot.

<!-- Costs: -->

Decision costs:

- Increased value of `cost_cues_default` from 0 to 1, so that default cue costs correspond to `mcu`.


## Details

- Fix bug for missing plot title.
- Added `@aliases FFTrees-package` to documentation of main `FFTrees()` function.
- Removed redundant `data_old` folder.

Expand Down Expand Up @@ -498,6 +507,6 @@ Thus, the main tree building function is now `FFTrees()` and the new tree object

------

[File `NEWS.md` last updated on 2024-05-21.]
[File `NEWS.md` last updated on 2024-09-04.]

<!-- eof. -->
15 changes: 9 additions & 6 deletions R/plotFFTrees_function.R
Original file line number Diff line number Diff line change
Expand Up @@ -1640,7 +1640,7 @@ plot.FFTrees <- function(x = NULL,
# print(lloc) # 4debugging


# Classification table: ----
# Classification table: 2x2 matrix / confusion matrix: ----

if (show.confusion) {

Expand Down Expand Up @@ -1695,16 +1695,19 @@ plot.FFTrees <- function(x = NULL,
decision.labels[1], adj = 1
)

# Adjust row category label:
if (data == "test") {
row_lbl <- "Prediction"
} else { # default:
row_lbl <- "Decision"
}

text(
x = final_classtable_x[1] - .065,
y = mean(final_classtable_y), cex = header_cex,
"Decision"
row_lbl
)

# text(x = final_classtable_x[1] - .05,
# y = mean(final_classtable_y), cex = header_cex,
# "Decision", srt = 90, pos = 3)


# Add final frequencies: ----

Expand Down
6 changes: 5 additions & 1 deletion R/util_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,11 @@ get_x_dev <- function(string, csf = .80){
# csf: constant scaling factor
# Returns a difference value that depends on string width (from min = .15 upwards).

n_char <- nchar(string)
if (!is.na(string)) {
n_char <- nchar(string)
} else {
n_char <- 0
}

if (n_char > 15){ # widen rectangle:

Expand Down

0 comments on commit a04a708

Please sign in to comment.