FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Feature Request: Controlling top, bottom, left, and right tick parameters independently of one another · Issue #11837 · matplotlib/matplotlib · GitHub

Repository navigation

Feature Request: Controlling top, bottom, left, and right tick parameters independently of one another #11837

Closed as not planned

Description

matplotlib.axes.Axes.tick_params allows one to control the direction which the ticks along the x and y axes point. Currently this can either be set to in or out which is very useful, but sometimes I want to create a plot that has ticks along the bottom pointing out and ticks along the top pointing in and I was unable to find an easy solution to accomplish this as tick_params for top and bottom are both tied to the x-axis. I am currently able to accomplish what I want by using and ax.twiny():

fig, ax = plt.subplots()

majorLocator = AutoLocator()
minorLocator = AutoMinorLocator()

ax_top = ax.twiny()
ax_top.tick_params(which='both', direction='in')
ax_top.set_xlim(ax.get_xlim())

ax.xaxis.set_minor_locator(minorLocator)
ax.xaxis.set_major_locator(majorLocator)

ax_top.xaxis.set_minor_locator(minorLocator)
ax_top.xaxis.set_major_locator(majorLocator)

ax_top.get_shared_x_axes().join(ax_top, ax)
ax_top.set_xticklabels([])


but this seems like a messy solution

Activity

  1. afvincent commented on Aug 9, 2018

    Contributor

    I agree that a more concise and user-friendly way to achieve this would be a nice feature to have from a user perspective. In some fields (at least the few ones that I know), these kinds of tick directions are rather common. For the record, a “recent” Gitter discussion related to the same topic occurred here.

  2. ImportanceOfBeingErnest commented on Aug 9, 2018

    Member

    If I see it correctly this should be simplified by the secondary_xaxis proposed in #11589, it should then look like (the API there is not yet finalized, so this is a rough estimate):

    fig, ax = plt.subplots()
    ax.minorticks_on()
    
    ax_top = ax.secondary_xaxis('top', 1)
    ax_top.minorticks_on()
    ax_top.tick_params(which='x', direction='in', labeltop=False)
    

    Even simpler solution would require something like proposed here.

  3. jklymak commented on Aug 15, 2018

    Member

    As #11859 (note new PR number) stands now, this is:

    import numpy as np
    import matplotlib.pyplot as plt
    
    convert = 1
    
    fig, ax = plt.subplots()
    
    ax.minorticks_on()
    
    axsecond = ax.secondary_xaxis('top', conversion=convert)
    axsecond.minorticks_on()
    axsecond.tick_params(axis='x', which='both', direction='in', labeltop=False)

    However if the xaxis has customized Locators and Formatters, these will not (currently) be shared with the secondary axes. Worse, I don't quite have a good API for setting the secondary axes Locators and Formatters, because they get reset every draw time to be consistent with the parent's scale (log or linear). This is a pretty big issue with #11859 at the momment, but hopefully we can work something out.

  4. github-actions commented on May 12, 2023

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

  5. added
    status: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.
    on Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    New featurestatus: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.status: inactiveMarked by the “Stale” Github Action

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL