-
Notifications
You must be signed in to change notification settings - Fork 7
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
Spineplots and spinograms for factor y-variables #233
base: main
Are you sure you want to change the base?
Conversation
First questions:
|
What functions consume these arguments? With your current code, the variables themselves should already be available in the
What "shape" do these arguments have? One simple option might be to use |
The Regarding the extra arguments: The most prominent case are the As they are neither a scalar, nor of length "n", I did not put them as a column in You could argue that I ought to |
If we think users will want to specify xaxs = yaxs = NULL just before
Here's one idea: In the main Since every |
…ass them on to draw_facet_window() where they are set via par()
Great, Vincent @vincentarelbundock, very useful. I've added the |
And nice idea with the I didn't do extensive tests, yet, but I think that Next I want to polish the faceted displays and then have a stab at handling
|
Very, very cool!
I don't know about margins. Paging @grantmcdermott
I see a |
Very exciting 🚀
Yes. That's the Reading and typing quickly on my phone, so I hope I didn't misunderstand the question. I'll be able to look properly in an hour or so. Edit: Details and default values here. https://grantmcdermott.com/tinyplot/man/tpar.html#additional-graphical-parameters |
Thanks, Grant. Then I see two ways of setting this:
2 is leaner but I guess 1 is cleaner? |
Yeah, I don't see a good reason to keep away too many things from type_draw(). Seems like a general design. |
RE: facet margin adjustments. Another option would be to check for Lines 127 to 152 in 068b431
E.g. In the last bit of the above code chunk, we subtract 0.5 lines from the Summarising: maybe we just try adding the following below line 152?
|
…is(4) in the panels on the right, increase default facet margins
Thanks for the advice, as usual very helpful. I now did the following:
|
Thanks @zeileis, I'll take a look. Would this supplant (duplicate?) the existing logic that we use here for only drawing axes of "outer" facets if the plot frame is turned off? Lines 38 to 39 in 068b431
and https://github.com/grantmcdermott/tinyplot/blob/main/R/facet.R#L250-L265 |
…port, refined axis type and lwd handling
Thanks, Grant, I overlooked that feature. Why is that logic only applied if there is no For spineplots, at the moment, I always repeat axis 1 and 3 but axis 4 is only shown for the last panel in a row. But I'm happy to adapt |
SummaryThe My latest additions are:
Examples
ProblemsLegend symbols: Note that I have to set Colors: Often one would want to select a single set of colors coding the levels of the y-variable like this: Users transitioning from
For now, I have worked around this by giving the
|
Whoa, these look great. I'll try to do a proper review tomorrow. (@vincentarelbundock please feel free to jump in first if you have time.) Really excited to see this long-standing issue nearing a resolution! |
Honestly, I wasn't sure whether we would really get here because there were so many special cases in the old monolithic code 🙈 Also I expected the modularization to be even more complicated. But Vincent's trick of passing a lot of arguments to the workers which can then overwrite them via |
Me neither 😭 |
How did you come across this idea? Was this Grant's input? (I didn't follow the details about the initial discussion of the modularization.) Bonus question: The standard design for |
No, I just started by returning a bunch of arguments in a list and reassigning them. Then, I got lazy and used list2env() as a hack. Only later I realized it was kind of a neat trick. Don't have a great idea now, and I'm not going to be able to concentrate on this for a few days at least since it's holiday here. Sorry! |
That's perfectly fine! I should really be doing other things as well (not vacations unfortunately). So I'll wait for Grant's feedback first and then return to handling the |
Sorry, I haven't had time to review this properly. I also have to head out of town now... but I just pushed a simple tweak (workaround) that gives square legend symbols. pkgload::load_all("~/Documents/Projects/tinyplot")
#> ℹ Loading tinyplot
ttnc = as.data.frame(Titanic)
tinyplot(Survived ~ Sex | Class, facet = "by", data = ttnc, weights = ttnc$Freq, type = type_spineplot(),
palette = "Dark 2", facet.args = list(nrow = 1), axes = "t") It's a bit hacky and I'll also flag that the bespoke coloring override here means that we don't match the offset black correctly. For example, see the legend key for "1st" is darker than the plot region here. tinyplot(Survived ~ Sex | Class, facet = "by", data = ttnc, weights = ttnc$Freq, type = type_spineplot(),
facet.args = list(nrow = 1), axes = "t") More generally, I need to think about the best way to pass arguments like |
Grant, thanks for this! Some comments and thoughts below. Nothing urgent, so feel free not to respond any time soon...
|
I don't think you're missing something. Or, at least, I didn't see how to do it either. Speaking of which...
Yeah, this is a great shout-out. I don't know if we (collectively) have the time to fix this before the next release... which I was hoping to push through within the next week or two, once this gets merged. But doing so would greatly simplify / negate some of the legacy workaround that we've carried through from pre-modularization. (Basically, just +1 to your final bullet point.) |
Fixes #2
This PR will eventually support spineplots (factor ~ factor) and spinograms (factor ~ numeric) using the
type_
infrastructure from the epic #222There is already some good progress. For example, you can do:
But as you can see the axis labeling is not great and the
by
handling does not work properly, yet. I will ask various questions, mostly to you Vincent @vincentarelbundock, I'm afraid. But I'm optimistic that we can sort out the details.tbc