Giter Club home page Giter Club logo

Comments (2)

AllanCameron avatar AllanCameron commented on July 4, 2024

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)

image

from geomtextpath.

AllanCameron avatar AllanCameron commented on July 4, 2024

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)

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.