Giter Club home page Giter Club logo

Comments (3)

teunbrand avatar teunbrand commented on July 24, 2024

Hi there,

Have you tried playing around with the hjust aesthetic? It control where along the line text is placed. See also this part of the vignette.

from geomtextpath.

AllanCameron avatar AllanCameron commented on July 24, 2024

You can set the hjust to any value between 0 and 1, or you can map it to an aesthetic (we have included scale_hjust_* functions for this very purpose, which by default dodge labels), or you can even set it to "auto"

library(tidyverse)
library(geomtextpath)

set.seed(2022)
tibble(x = seq(0, 1, 0.01),
       a_fairly_long_label = rnorm(x, mean = 0, sd = 1),
       b_fairly_long_label = rnorm(x, mean = 0.5, sd = 1)
) %>%
  pivot_longer(cols = c(a_fairly_long_label, b_fairly_long_label), 
               names_to = "group", values_to = "y") %>%
  ggplot(aes(x, y, linetype = group)) +
  #geom_smooth(se = FALSE) +
  geom_labelsmooth(aes(label = group), method = "loess", formula = y ~ x,
                   se = FALSE, hjust = "auto") +
  theme_minimal() +
  theme(legend.position = "none")

Created on 2022-02-23 by the reprex package (v2.0.1)

from geomtextpath.

dmoul avatar dmoul commented on July 24, 2024

Wow, very good! Thanks for the explanation. For anyone who comes along after and is reading this:

  • using hjust = 0.2 will put both labels in this case on the left side of the cross-over.
  • using hjust = "auto" in this case puts them at opposite ends as shown above.

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.