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

bwplot: Cannot remove y-axis labels with scales$y$labels = NULL #26

Open
stefaneng opened this issue Jan 6, 2023 · 2 comments
Open

Comments

@stefaneng
Copy link
Contributor

stefaneng commented Jan 6, 2023

y-axis labels can be removed by setting scales$y$labels = NULL in lattice::xyplot, lattice::histogram, and others but it does nothing when using lattice::bwplot.

Example:

library(lattice)
set.seed(10)
simple.data <- data.frame(
    x = rnorm(100),
    y = sample(1:5, replace = T, size = 100)
    )
# scales$y$labels = NULL removes yaxis labels for other plot types
lattice::xyplot(y ~ x, data = simple.data, scales=list(y=list(labels=NULL)))

lattice::histogram(simple.data$x, scales=list(y=list(labels=NULL)))

# Does not work to remove y-axis labels in bwplot
lattice::bwplot(y ~ x, data = simple.data, scales=list(y=list(labels=NULL)))

# Works fine to remove xaxis labels
lattice::bwplot(y ~ x, data = simple.data, scales=list(x=list(labels=NULL)))

Created on 2023-01-06 with reprex v2.0.2

@m-jahn
Copy link

m-jahn commented Jan 9, 2023

I can confirm this. As a workaround you can use something like:

lattice::bwplot(y ~ x, data = simple.data, scales=list(y=list(labels=rep("", 5))))

But of course, that's not a fix of the inconsistent behavior.

@deepayan
Copy link
Owner

deepayan commented Jan 9, 2023

Well, labels=NULL is not documented to be a valid choice, so the behaviour is undefined. The reason for the inconsistency is that xyplot() and bwplot() have different "defaults" for scales.

My suggestion would be to either use

scales=list(y=list(at = numeric(0)))

(documented, but no tick marks), or

default.scales = list(y=list(labels = NULL))

(technically undefined, but likely to work for the foreseeable future).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants