Comments (9)
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.
@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.
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.
Just making a small note here: if we do this, we might as well do geom_abline()
.
from geomtextpath.
Amazing! so is this (geom_texthline) already on the current git version?
from geomtextpath.
Yes, @akarlinsky - just reinstall and it's good to go.
from geomtextpath.
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.
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.
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)
- 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.