Giter Club home page Giter Club logo

Comments (9)

AllanCameron avatar AllanCameron commented on July 4, 2024 1

Hi @akarlinsky and thanks for your kind words. We weren't too fussed about creating hline and vline variants because these never need to be curved. However, the direct labelling and broken line aspects might make these useful additions.

You are correct that the approach to this is via geom_textsegment. I have just written the implementation and documentation for geom_texthline and will do the same for geom_textvline.

The current behaviour is:

library(geomtextpath)
#> Loading required package: ggplot2

ggplot(mtcars, aes(mpg, disp)) + 
  geom_point() + 
  geom_texthline(yintercept = 200, label = "Threshold", hjust = 0.8)

Created on 2022-01-09 by the reprex package (v2.0.1)

@teunbrand it is straightforward to implement these, so for completeness I agree that geom_textabline and geom_labelabline should be added too.

from geomtextpath.

AllanCameron avatar AllanCameron commented on July 4, 2024 1

@akarlinsky ghe latest commit includes geom_textvline and geom_labelvline.

So now you can do:

library(geomtextpath)
#> Loading required package: ggplot2

ggplot(mtcars, aes(mpg, disp)) + 
  geom_point() + 
  geom_texthline(yintercept = 200, label = "displacement threshold", 
                 hjust = 0.8, color = "red4") +
  geom_textvline(xintercept = 20, label = "consumption threshold", hjust = 0.8,
                 linetype = 2, vjust = 1.2, color = "blue4")

and

ggplot(mtcars, aes(mpg, disp)) + 
  geom_point() + 
  geom_labelhline(yintercept = 200, label = "displacement threshold", 
                 hjust = 0.8, color = "red4") +
  geom_labelvline(xintercept = 20, label = "consumption threshold", hjust = 0.8,
                 linetype = 2, vjust = 1.4, color = "blue4")

Created on 2022-01-09 by the reprex package (v2.0.1)

from geomtextpath.

akarlinsky avatar akarlinsky commented on July 4, 2024

For now I've "hacked" it geom_textsegment.
Would you like a contribution of geom_texthline and geom_textvline based on geom_textsegment? I can give it a go :)

from geomtextpath.

teunbrand avatar teunbrand commented on July 4, 2024

Just making a small note here: if we do this, we might as well do geom_abline().

from geomtextpath.

akarlinsky avatar akarlinsky commented on July 4, 2024

Amazing! so is this (geom_texthline) already on the current git version?

from geomtextpath.

AllanCameron avatar AllanCameron commented on July 4, 2024

Yes, @akarlinsky - just reinstall and it's good to go.

from geomtextpath.

akarlinsky avatar akarlinsky commented on July 4, 2024

FANTASTIC. You have no idea how useful this is.
It used to be a pain to h/vline and then annotating it accordingly.
From my end I think the issue is closed, I think the new functions should be added to the main README.

Thanks again!

from geomtextpath.

AllanCameron avatar AllanCameron commented on July 4, 2024

Thanks for the suggestion @akarlinsky. I have added these geoms to the table in the readme and included the above example too. @teunbrand I'll add the geom_textabline and geom_labelabline over the next couple of days plus some unit tests.

from geomtextpath.

teunbrand avatar teunbrand commented on July 4, 2024

Nice work Allan, very quick too! I'm not in a hurry with geom_textabline(), take all the time you need :)

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.