Comments (6)
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.
Re-opened to serve as a reminder for a tutorial section on date labels and breaks.
from plotnine.
Use date_format from mizani.
+ scale_x_datetime(labels=date_format('%Y'))
from plotnine.
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.
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.
Submitted #35
from plotnine.
Related Issues (20)
- Does plotnine 0.12.3 work with mizani 0.10.0? HOT 3
- Additions to facets HOT 2
- ggtitle or labs(title=) align left instead of center after updating from 0.10.1 to 0.12.3 HOT 2
- geom_text: can't use nudge_y and position=dodge HOT 2
- plotnine figure of ipynb with vscode is displayed too much larger than jupyter HOT 1
- AttributeError: 'RangeDiscrete' object has no attribute 'range' when calling scale_y_discrete HOT 3
- Add specific gene labels to geom_point volcanoplot HOT 2
- Tutorial ValueError: Unrecognised timezone class HOT 1
- Conditional colors for element_text() HOT 1
- `stat_ecdf` add `pad` argument
- geom_text cannot change vertical or horizontal alignment HOT 4
- Colored segments with manual group assignment breaks geom_path line endings
- No upper outline in `geom_ribbon()`
- Error when pickling an object obtained by draw() HOT 3
- Using a ggplot figure as standard Matplotlib device HOT 1
- Can the plotnine module draw significance markers? HOT 2
- In-place string scalars in `aes` HOT 1
- facet_grid throws an error: ValueError: No objects to concatenate HOT 2
- Breaks and labels in scale_color_identity don't match.
- FIPS Compliant
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 plotnine.