Skip to content

title doesn't move for ticklables.... #13735

Closed
@jklymak

Description

@jklymak

Bug report

Per https://stackoverflow.com/questions/55289921/matplotlib-matshow-xtick-labels-on-top-and-bottom @ImportanceOfBeingErnest

As of #9498, we have an _update_title_pos, but I guess it only checks for the xlabel, and not the tick labels. Should be relatively straightforward to fix I think...

import pandas as pd
import numpy as np
import string
import matplotlib.pyplot as plt

n = 10
names = ['Long Name ' + suffix for suffix in string.ascii_uppercase[:n]]

fig = plt.figure(constrained_layout=True)
ax = plt.gca()

ax.set_xticks(np.arange(n))
ax.set_xticklabels(names)
ax.set_yticks(np.arange(n))
ax.set_yticklabels(names)

# Set ticks on both sides of axes on
ax.tick_params(axis="x", bottom=True, top=True, labelbottom=True, labeltop=True)
# Rotate and align bottom ticklabels
plt.setp([tick.label1 for tick in ax.xaxis.get_major_ticks()], rotation=45,
         ha="right", va="center", rotation_mode="anchor")
# Rotate and align top ticklabels
plt.setp([tick.label2 for tick in ax.xaxis.get_major_ticks()], rotation=45,
         ha="left", va="center",rotation_mode="anchor")

ax.set_title("Name Co-Occurrences")
plt.show()

Figure_1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions