Changing the alpha line in the marine factor
1 answer
Find suitable axis objects FacetGrid
using the method get_children()
and set alpha for lines and markers. To change the marker property in the legend (object g._legend
), find the appropriate element legendHandles
and apply the method set_alpha()
:
import seaborn as sns
import matplotlib.pylab as plt
sns.set(style="ticks")
exercise = sns.load_dataset("exercise")
g = sns.factorplot(x="time", y="pulse", hue="kind", data=exercise)
# set alpha for marker (index 0) and for the rest line (indeces 3-6)
plt.setp([g.ax.get_children()[0],g.ax.get_children()[3:7]],alpha=.5)
# modify marker in legend box
g._legend.legendHandles[0].set_alpha(.5)
plt.show()
+3
source to share