X Tutup
Skip to content

Using tick_right() removes any styling applied to tick labels. #7020

@ghost

Description

Moving Y ticks on the right (tick_right(), set_label_position("right")) removes any styling applied to tick labels. Works ok for left-hand tick labels.

Any solution for this? I want to achieve conditional label styling (e.g. every other label is bold) based on label text.

  • Matplotlib 1.5.1
  • Python 3.5.2
  • installed with anaconda
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

fig, (ax_left, ax_right) = plt.subplots(1,2, figsize=(8, 4))
pd.Series(np.random.randint(0, high=10, size=10)).plot(kind='bar', ax=ax_left)

for tick in ax_left.yaxis.get_major_ticks():
    tick.label.set_weight('bold') 
    tick.label.set_style('italic')

pd.Series(np.random.randint(0, high=10, size=10)).plot(kind='bar', ax=ax_right)

for tick in ax_right.yaxis.get_major_ticks():
    tick.label.set_weight('bold') 
    tick.label.set_style('italic')

ax_right.yaxis.tick_right()
ax_right.yaxis.set_label_position("right")

plt.show(); 

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup