-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Use label-attribute as default axis/legend title #4631
Comments
Does anyone have thoughts on this? The PR could also add support for the class |
I think this is likely to be a good idea. But it requires some thought to determine if it's ok to enable by default. It will affect existing plots, but generally in a positive way, and it generally won't affect publication ready plots because they should have already had their labels set manually. So I think a PR would be a great next step 😄 |
This seems reasonable to implement when a mapping is a straightforward symbol, e.g. |
I think it would only apply to simple mappings. |
Currently, axis and legend titles default to the column names of the data.frame. There are several packages that provide functions to attach more comprehensive variable labels to data.frame columns (e.g.,
Hmsic
,tinylabels
,labelled
, andsjlabelled
). While these packages differe with respect to the specific implementation, all implementations are compatible in the sense that they attach the variable labels to the data.frame colums via thelabel
attribute. I think it would be useful to use such labels, if available, as they can probably be expected to be more informative than the bare column names.Consider the following example. First, I'll create some labelled data (I think
tinylabels
provides the safest implementation, but any of the below will work).For demonstration purposes I slightly change
ggplot_add.labels
to use thelabel
attribute, if available:With this change axis and legend labels will default to the
labels
attribute whenlabs()
is called:I think this would be very nice feature and I'd be happy to take a stab at it.
If this is of interest, I see three options for a proper implementation:
labs()
is called (pretty much what I have implemented above).labs()
is called and labels are requested (e.g.,use_labels = TRUE
).There are probably other sensible options that I'm not seeing. Either way, I'd be very interested to know if this would be a PR you would be willing to consider and in any thoughts you may have on this.
The text was updated successfully, but these errors were encountered: