Giter Club home page Giter Club logo

Comments (8)

AllanCameron avatar AllanCameron commented on July 4, 2024 1

I have implemented geom_labeldensity2d in the latest commit. I know we haven't addressed the "flattest point" issue, but I feel that this is a separate issue, so I will close this "Labelled contour lines" issue for now.

from geomtextpath.

teunbrand avatar teunbrand commented on July 4, 2024

when I realized that...we already have

Haha, that made me chuckle!
Is there anything that we could add beyond simply the convenience? For example with your reprex, would we want to offer the option to label only one of the outer paths that are broken up by the plot limits (personally I think it is 'correct' to label them all)? Are you considering stat_density2d() as well as stat_contour()?

On a note that just occurred to me looking at the plot, do we want to make the 'padding'/'breathing room' adjustable?

from geomtextpath.

AllanCameron avatar AllanCameron commented on July 4, 2024

I thought we had made padding adjustable, but I see now that we haven't. It's certainly a parameter within some of the internal functions, so it should be easy enough to expose it to end-users.

I think the labelling looks good as-is. The only thought that occurs is that you might want the label appearing more than once on the path. This ties in with something you mentioned before about having repeated labels along a path. This would be a nice additional feature, but it would be a bit of a headache to implement, requiring an overhaul of .get_surrounding_lines and .get_path_points

The examples I have added to the readme demonstrate both stat_contour and stat_density2d (which actually calls stat_contour internally after it has called kde2d).

I was thinking more of a convenience wrapper geom, but not sure how necessary that is.

from geomtextpath.

teunbrand avatar teunbrand commented on July 4, 2024

Well the repeated label thing I had I mind would be as easy as:

label <- "Repeat me!"
before_measurement <- paste0(rep(label, 12), collapse = " ")

Wherein the 12 should be replaced by a number large enough to cover the path, but I can also see the merit of having a more limited number of repeats. I agree it would be a headache to implement, so we could avoid doing it until more use-cases would require it.

A convenience wrapper sounds nice if you're motivated to make one (but no pressure, it is not an essential feature, I think). If you're looking for some inspiration, the metR package also has some contour labelling options.

from geomtextpath.

AllanCameron avatar AllanCameron commented on July 4, 2024

I have now exposed the padding argument in geom_labelcontour which definitely improves the look. I will implement the 2d density next. It was a little more complicated than I thought to wrap the labelled contours in their own geom, since getting the labels passed through required a new stat as well.

The main feature that metR seems to offer is that it places the label on the flattest part of the curve. I'm not sure how big a difference this makes, but if there was an algorithm to do that for general paths and not just contours, we might be able to have a (?default) "auto" setting on the hjust in the that tries to put the labels in a nice spot. I'm not sure how hard this will be, but again the curvature might help us here.

from geomtextpath.

teunbrand avatar teunbrand commented on July 4, 2024

Isn't searching for the flattest part of a curve equivalent to finding the angles that are closest to zero or multiples of 2*pi? If you want to get more fancy, you can search in a textwidth-sized window for the smallest average absolute angle. It could be nice to have this for regular geom_textpath() as well. Probably .anchor_points() is the appropriate place for such logic.

from geomtextpath.

AllanCameron avatar AllanCameron commented on July 4, 2024

It could be nice to have this for regular geom_textpath() as well.

Yes, that's what I was thinking - perhaps allowing an "auto" hjust to be interpreted as "place the text on the flattest part of the path". Though, having said that, it seems a shame to write a package for curved text only to have it default to flat text!

from geomtextpath.

teunbrand avatar teunbrand commented on July 4, 2024

a shame to write a package for curved text only to have it default to flat text

Well we can just make hjust = "auto" a default in the contour plots, but not in the textpath plots. Its probably just for legibility. In textpath plots it would just be an option to search for the flattest part and default to hjust = 0.5.

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.