Skip to content

tinyplot not working with layout? #329

Open

Description

@devSJR

I was trying to use tinyplot with layout. However, there appears to be an issue.

works: all plots basically are drawn, but not in the matrix layout

layout(matrix(c(1, 1, 1, 1, 2, 2, 3, 3), nrow = 2, ncol = 4, byrow = TRUE ))

tinyplot(Petal.Width ~ Sepal.Width | Species, data = iris)
tinyplot(Sepal.Width ~ Petal.Length | Species, data = iris)
tinyplot(Petal.Width ~ Petal.Length | Species, data = iris)

doesn't work: all plots basically are drawn in the matrix layout, when the by argument is not used (both with by and formula syntax)

layout(matrix(c(1, 1, 1, 1, 2, 2, 3, 3),
  nrow = 2, ncol = 4, byrow = TRUE
))

tinyplot(Petal.Width ~ Sepal.Width, data = iris)
tinyplot(Sepal.Width ~ Petal.Length, data = iris)
tinyplot(Petal.Width ~ Petal.Length, data = iris)

Activity

  1. grantmcdermott commented on Feb 28, 2025

    @grantmcdermott
    Owner

    Yeah, unfortunately we probably have to mark this as won't fix. The tl;dr version is that tinyplot needs to hijack the window arrangement to position things the legend, facet, etc. Internally, we use par(mfrow) & co. for this, which as you probably know, makes it incompatible with layout.

    OTOH, turning the legend off does work:

    library(tinyplot)
    
    layout(matrix(c(1, 1, 1, 1, 2, 2, 3, 3), nrow = 2, ncol = 4, byrow = TRUE ))
    
    tinyplot(Petal.Width ~ Sepal.Width | Species, data = iris, legend = FALSE)
    tinyplot(Sepal.Width ~ Petal.Length | Species, data = iris, legend = FALSE)
    tinyplot(Petal.Width ~ Petal.Length | Species, data = iris, legend = FALSE)

    Created on 2025-02-27 with reprex v2.1.1

  2. devSJR commented on Feb 28, 2025

    @devSJR
    Author

    Alright. Would it be possible to give a(n) warning/error message in case layout is used? Something like trace(layout)?

  3. grantmcdermott commented on Mar 1, 2025

    @grantmcdermott
    Owner

    Thanks @devSJR that's a good suggestion. At a minimum, we could probably do a better job of documenting this incompatibility.

    I want to take a another stab at improving layout compatibility with the legend behavior, though. It feels to me like maybe we could get this to work, even if facets are a no-go. But I'll only be able to take a look at it in a few weeks.

  4. devSJR commented on Mar 1, 2025

    @devSJR
    Author

    Sure, all good. I think communicating this more prominent will do the trick for the time being. Technical solutions would be optimal of course, but from my side at least there's no need to hurry. Keep up the good work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions