Skip to content

Horizontal and vertical text alignment not working on set_rgrids() #10105

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
OD1995 opened this issue Dec 27, 2017 · 5 comments
Closed

Horizontal and vertical text alignment not working on set_rgrids() #10105

OD1995 opened this issue Dec 27, 2017 · 5 comments

Comments

@OD1995
Copy link

OD1995 commented Dec 27, 2017

Bug report

Bug summary

Horizontalalignment and verticalalignment text properties for set_rgrids() do not work. Have tried other text properties, such as style and color, and they do work.

Code for reproduction

import matplotlib.pyplot as plt
import numpy as np

variables = ("var1","var2","var3","var4")
data = (5,10,100,1.25)
ranges = [(0,5),(5,15),(50,110),(2,1)]

angles = np.arange(0, 360, 360./len(variables))
angles0 = np.deg2rad(np.r_[angles, angles[0]])

n_ordinate_levels=6

fig1 = plt.figure(figsize=(6,6))

rectangle = [0.1,0.1,0.8,0.8]

ax1 = fig1.add_axes(rectangle,polar=True,label='ax1')
ax2 = fig1.add_axes(rectangle,polar=True,label='ax2')
ax3 = fig1.add_axes(rectangle,polar=True,label='ax3')
ax4 = fig1.add_axes(rectangle,polar=True,label='ax4')

ax00 = [ax1,ax2,ax3,ax4]


l, text = ax1.set_thetagrids(angles,labels=variables)
for j in range(len(ax00)-1):
            ax00[j+1].patch.set_visible(False)
            ax00[j+1].grid("off")
            ax00[j+1].xaxis.set_visible(False)
 
    
for i in range(len(ax00)):
    grid = np.linspace(*ranges[i], 
                       num=n_ordinate_levels)
    gridlabel = ["{}".format(round(x,2)) 
                 for x in grid]
    grid0 = [0,0.2,0.4,0.6,0.8,1]
    gridlabel[0] = "" # clean up origin
    ax00[i].set_rgrids(grid0, labels=gridlabel,
                 angle=angles[i], horizontalalignment = 'center',
                 verticalalignment = 'center')
    ax00[i].spines["polar"].set_visible(False)
    ax00[i].set_ylim(bottom=0,top=1)

Actual outcome

No text alignment

Expected outcome

Radial axe labels to be aligned centrally, both vertically and horizontally

Matplotlib version

  • Operating system: Windows 10
  • Matplotlib version: 2.1.0
  • Matplotlib backend (print(matplotlib.get_backend())): module://ipykernel.pylab.backend_inline
  • Python version: 3.6.3
  • Jupyter version (if applicable):
  • Other libraries:

Matplotlib/Python downloaded with Anaconda

@pbregener
Copy link

pbregener commented Feb 19, 2018

This unfortunately appears to be a regression in v2.1.0. The alignment works fine in v2.0.2. I guess it is related to the massive changes from #4699? Thoughts @QuLogic?

Edit: Might also be related to the follow-up PRs #9068 and #9881

Does anyone have a workaround?

@pbregener
Copy link

Can you confirm this @QuLogic? Would love to see this fixed (and help doing so, if I can) in the near future, as I've seen cases where the radius labels were misleading due to wrong horizontal and vertical alignment (they may appear to be offset by one tick).

@pbregener
Copy link

cc @tacaswell for regression triaging/scheduling

@pbregener
Copy link

PR #10792 should have closed this

@jklymak jklymak closed this as completed May 22, 2018
@jklymak
Copy link
Member

jklymak commented May 22, 2018

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants