Skip to content

Offset text positions not implemented #4476

Open
@joferkington

Description

@joferkington

There currently isn't any method of controlling where offset text for an axis gets placed. This causes problems when changing tick locations (e.g. tick_top and tick_right).

Axis.offset_text_position appears to have been intended to be the control, but changing ax.xaxis.offset_text_position and ax.yaxis.offset_text_position has no effect. Furthermore, there doesn't appear to be a code path where offset_text_position is used, or any other mechanism for changing the offset text's position. XAxis._update_offset_text_position (and the equivalent in YAxis) will need to be updated to take this into account.

Consider the following example:

import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0, 1e8)
y = np.exp(x**0.2)

fig, ax = plt.subplots()
ax.plot(x, y)

ax.xaxis.tick_top()
ax.yaxis.tick_right()

plt.show()

figure_1

In this case, the 1e17 corresponds to the y-axis, while the 1e8 corresponds to the x-axis. Ideally, these should be aligned so that it's clear which axis they correspond to.

For the y-axis, we can move the offset text to the left-hand side, but it will still be in a position that overlaps with the x-axis's ticklabels. Regardless, there's no corresponding method for the x-axis. As an example:

import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0, 1e8)
y = np.exp(x**0.2)

fig, ax = plt.subplots()
ax.plot(x, y)

ax.xaxis.tick_top()
ax.yaxis.tick_right()
ax.yaxis.set_offset_position("right")

plt.show()

figure_1

Note: Originally noticed by user3160855 in a Stackoverflow question.

Metadata

Metadata

Assignees

No one assigned

    Labels

    New featurekeepItems to be ignored by the “Stale” Github Actionstatus: has patchpatch suggested, PR still needed

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy