Code Monkey home page Code Monkey logo

Comments (6)

lorin avatar lorin commented on May 22, 2024 1

That's pretty close, but not quite what I wanted. However, it did help me figure out what I really wanted was this:

+ scale_x_datetime(labels=lambda lst: [x.year if x.month==1 and x.day==1 else "" for x in lst])

As an aside, the scale docs describe the labels argument as a list, specifically:

labels (list, optional) – List of str. Labels at the breaks.

However, given the answer above, it appears that the labels argument can also be a callable that takes a list (array_like?) of breakpoints as input and returns a list of strings as output.

Should the docs be updated? If so, I'm willing to submit a PR.

from plotnine.

has2k1 avatar has2k1 commented on May 22, 2024 1

Re-opened to serve as a reminder for a tutorial section on date labels and breaks.

from plotnine.

has2k1 avatar has2k1 commented on May 22, 2024

Use date_format from mizani.

+ scale_x_datetime(labels=date_format('%Y'))

from plotnine.

has2k1 avatar has2k1 commented on May 22, 2024

Yes the docs should be updated and a PR would be great. Also, can you add something for the breaks argument. It can be a callable that takes a tuple of limits and returns a list of breaks.

Plus, would something of the sort

+ scale_x_datetime(breaks=date_breaks('2 year'), labels=date_format('%Y'))

have worked for you.

from plotnine.

lorin avatar lorin commented on May 22, 2024

This was exactly what I was looking for:

+ scale_x_datetime(breaks=date_breaks('1 year'), labels=date_format('%Y'))

I'll submit a PR for the docs.

from plotnine.

lorin avatar lorin commented on May 22, 2024

Submitted #35

from plotnine.

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.