Comments (8)
I have implemented geom_labeldensity2d
in the latest commit. I know we haven't addressed the "flattest point" issue, but I feel that this is a separate issue, so I will close this "Labelled contour lines" issue for now.
from geomtextpath.
when I realized that...we already have
Haha, that made me chuckle!
Is there anything that we could add beyond simply the convenience? For example with your reprex, would we want to offer the option to label only one of the outer paths that are broken up by the plot limits (personally I think it is 'correct' to label them all)? Are you considering stat_density2d()
as well as stat_contour()
?
On a note that just occurred to me looking at the plot, do we want to make the 'padding'/'breathing room' adjustable?
from geomtextpath.
I thought we had made padding adjustable, but I see now that we haven't. It's certainly a parameter within some of the internal functions, so it should be easy enough to expose it to end-users.
I think the labelling looks good as-is. The only thought that occurs is that you might want the label appearing more than once on the path. This ties in with something you mentioned before about having repeated labels along a path. This would be a nice additional feature, but it would be a bit of a headache to implement, requiring an overhaul of .get_surrounding_lines
and .get_path_points
The examples I have added to the readme demonstrate both stat_contour
and stat_density2d
(which actually calls stat_contour
internally after it has called kde2d
).
I was thinking more of a convenience wrapper geom, but not sure how necessary that is.
from geomtextpath.
Well the repeated label thing I had I mind would be as easy as:
label <- "Repeat me!"
before_measurement <- paste0(rep(label, 12), collapse = " ")
Wherein the 12
should be replaced by a number large enough to cover the path, but I can also see the merit of having a more limited number of repeats. I agree it would be a headache to implement, so we could avoid doing it until more use-cases would require it.
A convenience wrapper sounds nice if you're motivated to make one (but no pressure, it is not an essential feature, I think). If you're looking for some inspiration, the metR package also has some contour labelling options.
from geomtextpath.
I have now exposed the padding argument in geom_labelcontour
which definitely improves the look. I will implement the 2d density next. It was a little more complicated than I thought to wrap the labelled contours in their own geom, since getting the labels passed through required a new stat as well.
The main feature that metR seems to offer is that it places the label on the flattest part of the curve. I'm not sure how big a difference this makes, but if there was an algorithm to do that for general paths and not just contours, we might be able to have a (?default) "auto" setting on the hjust in the that tries to put the labels in a nice spot. I'm not sure how hard this will be, but again the curvature might help us here.
from geomtextpath.
Isn't searching for the flattest part of a curve equivalent to finding the angles that are closest to zero or multiples of 2*pi? If you want to get more fancy, you can search in a textwidth-sized window for the smallest average absolute angle. It could be nice to have this for regular geom_textpath()
as well. Probably .anchor_points()
is the appropriate place for such logic.
from geomtextpath.
It could be nice to have this for regular
geom_textpath()
as well.
Yes, that's what I was thinking - perhaps allowing an "auto" hjust to be interpreted as "place the text on the flattest part of the path". Though, having said that, it seems a shame to write a package for curved text only to have it default to flat text!
from geomtextpath.
a shame to write a package for curved text only to have it default to flat text
Well we can just make hjust = "auto"
a default in the contour plots, but not in the textpath plots. Its probably just for legibility. In textpath plots it would just be an option to search for the flattest part and default to hjust = 0.5
.
from geomtextpath.
Related Issues (20)
- Option for line width and/or font size control when using 'size = ___' for geom_textsmooth() HOT 2
- geom_textsegment() with arrow() draws line to the top left of the plot HOT 4
- Denisty fill HOT 6
- label border? HOT 2
- geom_textsmooth() doesn't choose method if not explicitly set HOT 2
- Request something like "dodge" along path HOT 3
- Chinese character support HOT 3
- geom_labelsf() not recognizing aesthetics HOT 5
- While working with ragg, minuses aren't drawn HOT 2
- geom_textpath() always draw a empty box when label is ""
- Ignoring unknown parameters: text_smoothing HOT 10
- Feature request - multiple labels per line HOT 7
- geom_textsmooth computation fails if method argument is not specified HOT 3
- ggplot2 is separating size and linewidth HOT 2
- Negative values in geom_textcontour not appearing HOT 1
- geom_textlinerange HOT 1
- Question on angle
- text_only in geom_labelsegment
- Feature request - avoid text overlapping
- two labels on same curve HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from geomtextpath.