Comments (2)
I have started implementing this. My approach was to keep the labels flat but angled rather than trying to curve them. Expressions need to be handled differently from text, but I thought the best thing to do was to try to create the same output structure that measure_text
produces. This can't be done exactly, since you can't easily fit multiple expressions in a data frame column. However, we can do it in a list, so that mostly the same accessors and subsetters still work.
When we implement the "dumb" textpath, we should probably make every expression "dumb", though the placement is good on smooth curves at present.
Current behaviour is:
library(geomtextpath)
#> Loading required package: ggplot2
lab <- expression(paste("y = ", frac(1, sigma*sqrt(2*pi)), " ",
plain(e)^{frac(-(x-mu)^2, 2*sigma^2)}))
df <- data.frame(x = seq(-2, 0, len = 100),
y = dnorm(seq(-2, 0, len = 100)),
z = as.character(lab))
p <- ggplot(df, aes(x, y, label = z))
p + geom_textpath(vjust = -0.2, hjust = 0.1, size = 8, parse = TRUE)
and
ggplot() + xlim(0, 1) +
stat_function(fun = \(x) x, label = "paste('y = ', x)",
geom = "textpath", vjust = -0.2, parse = TRUE) +
stat_function(fun = \(x) x^2, label = "paste('y = ', x^2)",
geom = "textpath", vjust = -0.2, parse = TRUE) +
stat_function(fun = \(x) x^3, label = "paste('y = ', x^3)",
geom = "textpath", vjust = -0.2, parse = TRUE)
from geomtextpath.
The latest commit allows multiple parsed expressions and fixes some line spacing problems with the above implementation, so plotmath should have the same functionality as text.
from geomtextpath.
Related Issues (20)
- 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
- 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
- vjust and hjust as aesthetics in geom_textsf HOT 3
- Different behavior for line breaks when there's no data
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.