pwtools.mpl.color_ax¶
- pwtools.mpl.color_ax(ax, color, axis='y', spine_loc='left', spine_invisible=None)[source]¶
Change ax color.
- Parameters:
ax (AxesSubplot)
color (whatever matplotlib accepts as color, e.g. "b", "tab:green")
axis ("x", "y" or "both")
spine_loc (index for
ax.spines
,['left', 'right', 'bottom', 'top']
)spine_invisible (index for
ax.spines
or None) – Make this spine invsible, e.g. to uncover underlying spine. Useful in twinx() settings (see example below).
Examples
>>> color_left = "tab:red" >>> color_right = "tab:green"
>>> fig,ax = plt.subplots() >>> ax.plot(rand(10), color=color_left) >>> ax.set_ylabel("left")
>>> ax2 = ax.twinx() >>> ax2.plot(rand(10), color=color_right) >>> ax2.set_ylabel("right")
>>> mpl.color_ax(ax, color_left) >>> mpl.color_ax(ax2, color_right, spine_loc="right", ... spine_invisible="left")
Notes