Giter Club home page Giter Club logo

Comments (7)

AllanCameron avatar AllanCameron commented on July 4, 2024 1

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.

teunbrand avatar teunbrand commented on July 4, 2024 1

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.

AllanCameron avatar AllanCameron commented on July 4, 2024 1

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.

AllanCameron avatar AllanCameron commented on July 4, 2024

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.

tjebo avatar tjebo commented on July 4, 2024

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.

teunbrand avatar teunbrand commented on July 4, 2024

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.

teunbrand avatar teunbrand commented on July 4, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.