8000 Horizontal and vertical text alignment not working on set_rgrids() · Issue #10105 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Horizontal and vertical text alignment not working on set_rgrids() #10105
Closed
@OD1995

Description

@OD1995

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0