Comments (7)
Thanks @tjebo . I know this is something that @teunbrand had envisioned at an early stage of the package's development. I can't remember now if we shelved it for reasons of complexity or simply forgot about it. It's probably not as niche as you think. Repeated labels on longer paths, or multiple labels highlighting different features on a line could be helpful. I'm happy to look at this unless Teun has any objections.
from geomtextpath.
I think it is a good idea in principle. I don't know how difficult it would be to implement: I can imagine that we've foreseen only one label per line in places like calculating where the gaps should be. This could get hairy quite quickly, but it shouldn't be undoable. How would you imagine this on the user's end, simply a parameter that says rep_label = 5
or something of the sort?
from geomtextpath.
Another thought occured to me, we might be able to simply cheese this by splitting the line into several ones. Every individual linepiece would then be treated as a line, which would resolve potential nightmares with reserving space for multiple labels.
This sounds like the most promising approach, assuming the line joins are seamless.
@tjebo the hjust
is already handled as an aesthetic - in fact, we added specific scale_hjust_*
and scale_vjust_*
functions to control the mapping. I didn't think they would get much use, but they come in handy occasionally; in fact I used them earlier today with good effect
from geomtextpath.
If we allowed multiple different strings per line then the user interface probably becomes too complex (multiple hjust per string would be very difficult to implement and probably break existing hjust scales). I guess just allowing repeats and ignoring hjust (or reinterpreting it in the case of repeats) would be best.
from geomtextpath.
I think if you're indeed thinking of implementing it, then it would make sense to go all the way and allow different strings - and intuitively it would make sense to just pass the labels as an aesthetic. Maybe as a different one, e.g. "multi_labels" or so. Regarding hjust - of course I don't know how your magic really works under the hood, and it seems amazing, but I am not sure if hjust would be such a problem. For example, an often forgotten feature of hjust is that you can actually pass it as an aesthetic...
e.g. (random example)
library(ggplot2)
ggplot(head(mtcars)) +
geom_vline(aes(xintercept = mpg), lty = 2) +
## vs just contains 0 and 1
geom_label(aes(mpg, disp, label = gear, hjust = vs))
But yeah, this might be difficult to implement in your geom.
Created on 2022-05-29 by the reprex package (v2.0.1)
from geomtextpath.
multiple hjust per string would be very difficult to implement
Indeed, I think it'd just be undefined at that point.
There are different options on how to deal with text and spacing though, if we assume w
is text that we want to repeat up to 3 times and -
a unit of space, we can have:
w--w--w
-w--w--w-
--w--w--w--
I.e, do we put the text at the extremes, do we pad the ends with half-spacings or do we pad the ends with full spacing.
from geomtextpath.
Another thought occured to me, we might be able to simply cheese this by splitting the line into several ones. Every individual linepiece would then be treated as a line, which would resolve potential nightmares with reserving space for multiple labels.
from geomtextpath.
Related Issues (20)
- 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
- 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
- straight argument unknown in geom_textsf() HOT 2
- `label` aesthetic in `geom_textdensity2d` HOT 2
- R 4.3.0 and glyphs 👀 HOT 1
- Can't get things to work HOT 11
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.