How do I transform tick labels without explicitly specifying breaks?
See original GitHub issueLet’s say I have a scatter plot where the x-axis date is pandas.Timestamp objects. By default, plotnine renders the x tick labels on my plot such such that they run into each other.
I’d like to do an arbitrary transformation on the x-axis tick labels. For example, I’d like the tick labels to be blank except for the first day of the year, in which case I want the tick label to just be the year, so "2017-03-04"
would transform to ""
, and "2016-01-01"
would transform to "2016"
.
However, I don’t want to explicitly specify the breaks. Instead, I want plotnine to use its default algorithm for determining where to put the breaks.
Is this possible to do with plotnine?
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Conditional Formatting ggplot label ticks without explicitly ...
You can use the technique linked in the duplicate post and provide separate lists for the colour and face arguments:
Read more >Changing Axes
To adjust the number of minor ticks, you just change the number of minor breaks using the minor_breaks argument of the continuous scale...
Read more >Customizing Axes in D3.js - Glenn Henshaw
A beginners guide to unpacking and customizing the elements of a D3 axis ... tickSize(); Attributes of the .domain <path> element; Tick labels:...
Read more >ggplot2 axis ticks : A guide to customize tick marks and labels
Change the order of items; Change tick mark labels; Choose which items to display ... a character or numeric vector specifying which breaks...
Read more >10 Position scales and axes | ggplot2
In this example the y aesthetic is not specified by the user. ... It covers limits, breaks, and labels in Section 10.3.1 and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Re-opened to serve as a reminder for a tutorial section on date labels and breaks.
That’s pretty close, but not quite what I wanted. However, it did help me figure out what I really wanted was this:
As an aside, the scale docs describe the labels argument as a list, specifically:
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.