Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Colors a pain to define in qbarplot #33

Open
vertesy opened this issue Apr 10, 2023 · 2 comments
Open

Colors a pain to define in qbarplot #33

vertesy opened this issue Apr 10, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@vertesy
Copy link
Owner

vertesy commented Apr 10, 2023

Description

Colors a pain to define in qbarplot.
You can't easily provide a color vector as in wbarplot()

Details

qbarplot(xxx, col = 1)

qbarplot(xxx, col = 1)
qbarplot(xxx, col = 2) # has no effect
qbarplot(xxx, palette_use = "aaas", col = 2) # changes color

Alternating colors

qbarplot(xxx, col = 2:1)

To explicitly define colors you need to define it in palette

qbarplot(xxx, col = "brown")
qbarplot(xxx, col = c("brown", "orange")) # Wtf: now it reverts back to default palette and alternating colors

The above is the equivalent of:

qbarplot(xxx, col = 1:2) # and of qbarplot(xxx, col = 1:2, palette_use = "jco")

To explicitly define a SINGLE color you need to define it in palette

qbarplot(xxx, palette = "orange", col = 2) # has no effect

You cannot explicitly define a SET OF COLORS in qbarplot, you need to define it in palette and use col = 1:length(xxx)

qbarplot(xxx, palette = rich.colors(n = length(xxx)))

So the correct way to define a set of colors is:

qbarplot(xxx, palette = rich.colors(n = length(xxx)), col = 1:length(xxx))

This is super weird, and cumbersome, but it is probably due to the fact that qbarplot is a wrapper around ggpubr.

@vertesy vertesy added the bug Something isn't working label Apr 10, 2023
@vertesy
Copy link
Owner Author

vertesy commented Sep 12, 2024

Solution (not implemented)

qbarplot should repurpose the stupid palette and color options.

col

  1. NULL by default
  2. If provided, AND == len(xxx)
    palette = rich.colors(n = length(xxx)), col = 1:length(xxx))

@vertesy
Copy link
Owner Author

vertesy commented Sep 12, 2024

Seems to need a larger revamp

   col = as.character(1:3)[1],
    xlab = ...
    ...) {

# later

  df[["colour"]] <-
    if (length(col) == length(vec)) {
      as.character(col)
    } else if (hline & filtercol != 0) {
      if (filtercol == 1) (df$"value" > hline) else if (filtercol == -1) (df$"value" < hline)
    } else {
      as.character(rep(col, length(vec))[1:length(vec)])
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant