-
Notifications
You must be signed in to change notification settings - Fork 300
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
add text method #2399
add text method #2399
Conversation
I think this is a good idea, but please
Maybe |
Removing pipes gave me a good laugh - I forgot there was a time before pipes. |
#' each feature in \code{x}. Provide POINT features for full control of placement. | ||
#' @examples | ||
#' text(nc, labels = substring(nc$NAME,1,1)) | ||
text.sf = function(x, labels = row.names, ..., of_largest_polygon = FALSE){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
labels = row.names(x)
#' text(nc, labels = substring(nc$NAME,1,1)) | ||
text.sf = function(x, labels = row.names, ..., of_largest_polygon = FALSE){ | ||
x = st_geometry(x) | ||
x = st_centroid(x, of_largest_polygon = FALSE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
of_largest_polygon = of_largest_polygon
Thanks! |
Well, thank you for your patience with my embarrassing show. |
Next up would be |
Oh, geez, I hadn't thought of that. There is quite a menagerie that might be included...
I have been thinking about using |
too bad that |
I think I'll stop here, for |
Oooo, I see. I assumed that all of the graphics package functions were generic. Bummer. Well, thanks for |
Hi,
It very much appeals to my inner laziness to have a
text()
method. For anysf
object this will automatically place a label at each feature's centroid. If somebody wanted finer control, they could make a POINT table to plot. I know you don't want to add more stuff tosf
, but this feels pretty unobstrusive.What do you think?
Created on 2024-05-20 with reprex v2.0.2