Matplotlib Annotation Overlapping Y_tick Labels On Plot
I have tried a number of different things to fix my chart, from zorder on the plots to plt.rcParams. I feel that this is such a simple problem but I just dont know where I have gon
Solution 1:
I don't figure out why zorder
doesn't work, but you can directly set the label style of tick labels:
import matplotlib.pyplot as plt
import numpy as np
from numpy.random import rand
import matplotlib.patches as mpatches
fig, ax = plt.subplots(1, 1)
ax.plot(rand(100), '^', color='r')
for label in ax.get_xticklabels():
label.set_bbox(dict(facecolor='orange'))
ax1 = ax.twinx()
ax1.plot(rand(100), 'o', color='b')
index_to_add_bbox = [2, 4]
ax1_labels = ax1.get_yticklabels()
for i in index_to_add_bbox:
ax1_labels[i].set_bbox(dict(boxstyle='Circle', facecolor='orange'))
plt.show()
Post a Comment for "Matplotlib Annotation Overlapping Y_tick Labels On Plot"