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

Skip to content

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

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
jklymak opened this issue Mar 22, 2019 · 0 comments · Fixed by #13741
Closed

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

jklymak opened this issue Mar 22, 2019 · 0 comments · Fixed by #13741
Milestone

Comments

@jklymak
Copy link
Member

jklymak commented Mar 22, 2019

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

@jklymak jklymak added this to the v3.1.0 milestone Mar 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant