Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Number of ticks for dates still gives overlapping labels #7712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jorisvandenbossche opened this issue Dec 31, 2016 · 7 comments
Closed

Number of ticks for dates still gives overlapping labels #7712

jorisvandenbossche opened this issue Dec 31, 2016 · 7 comments
Labels
Difficulty: Medium https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues New feature topic: date handling
Milestone

Comments

@jorisvandenbossche
Copy link

Matplotlib 2.0 introduced better default tick locators to have a better (often less) number of ticks (http://matplotlib.org/devdocs/users/dflt_style_changes.html#number-of-ticks) that prevents overlap of ticklabels. Which is a really nice enhancement, only it seems that this enhancement is not working for datetime tick labels:

>>> import matplotlib
>>> import matplotlib.pyplot as plt
>>> matplotlib.__version__
'2.0.0rc2'
>>> import datetime
>>> dates = [datetime.datetime(2016,1,i) for i in range(1,30)]
>>> values = list(range(1,30))
>>> plt.plot(dates, values)
[<matplotlib.lines.Line2D object at 0x7f41327d2e80>]
>>> plt.show()

figure_1-2

This still gives the 'too much' tick labels like before (actually, the same plot but with integer x values gives fewer ticks).

Is there a technical reason for this? (the DateLocator using another mechanism to determine the number of ticks as the default AutoLocator)

Matplotlib 2.0.0rc2 (installed from conda-forge)

@efiring
Copy link
Member

efiring commented Dec 31, 2016

The AutoDateLocator uses a completely different mechanism to set the default max number of ticks. It has an internal table of max numbers depending on the unit of time it is working with, and there is no consideration of the physical size of the axis or of the font size. You can supply a max that overrides the default. You can also slant the tick labels as in http://matplotlib.org/devdocs/examples/api/date_demo.html.

I think that there is considerable room for improvement in the way we handle datetime ticking and labeling, but it needs to be left as a project for after the v2.0 release.

@efiring efiring added topic: date handling Difficulty: Medium https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues New feature labels Dec 31, 2016
@efiring efiring added this to the 2.1 (next point release) milestone Dec 31, 2016
@patniharshit
Copy link
Contributor

I would like to work on the issue. Where should I start with this?

@Shang-Jia
Copy link

Modified the AutoDateLocator to use the largest possible tickable size rather than the smallest. Should I submit a pull request? And what testcases/if any should be written for this?
capture

@ParagBh
Copy link

ParagBh commented Mar 6, 2017

@Shang-Jia

How did you get the daily interval to be every 6 days? If you look at the value of DAILY inside the self.intervald dictionary, the intervals can within a month can only be every 1, 2, 3, 7, 14, or 12 days because DAILY: [1,2,3,7,14,21]. So shouldn't the interval be either 1, 2, 3, 7, 14, and 21 and not 6? Please, correct me if I'm wrong.

@ParagBh
Copy link

ParagBh commented Mar 6, 2017

I think I may have a solution for this one but not sure if it's right. How exactly do I write testcases for this?

figure_1

@Shang-Jia
Copy link

Yeah, I was playing around with differing minticks and intervals as well

@tacaswell tacaswell modified the milestones: 2.1 (next point release), 2.2 (next next feature release) Oct 3, 2017
@jklymak
Copy link
Member

jklymak commented Jan 28, 2019

I'm going to close this as partially obviated by #10841. That new formatter is not the default, but does give the user a way to have more compact date labels.

In general, its going to be hard to make tick locating depend on tick formatting.

@jklymak jklymak closed this as completed Jan 28, 2019
@QuLogic QuLogic modified the milestones: needs sorting, v3.1 Jan 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty: Medium https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues New feature topic: date handling
Projects
None yet
Development

No branches or pull requests

8 participants