Python matplotlib.patheffects() Examples
The following are 1
code examples of matplotlib.patheffects().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
matplotlib
, or try the search function
.
Example #1
Source File: utils.py From dynamo-release with BSD 3-Clause "New" or "Revised" License | 5 votes |
def scatter_with_legend( fig, ax, df, font_color, x, y, c, cmap, legend, **scatter_kwargs ): import seaborn as sns import matplotlib.patheffects as PathEffects unique_labels = np.unique(c) if legend == "on data": g = sns.scatterplot( x, y, hue=c, palette=cmap, ax=ax, legend=False, **scatter_kwargs ) for i in unique_labels: color_cnt = np.nanmedian(df.iloc[np.where(c == i)[0], :2], 0) txt = ax.text( color_cnt[0], color_cnt[1], str(i), color=font_color, zorder=1000, verticalalignment="center", horizontalalignment="center", weight="bold", ) # c txt.set_path_effects( [ PathEffects.Stroke( linewidth=1.5, foreground=font_color, alpha=0.8 ), # 'w' PathEffects.Normal(), ] ) else: g = sns.scatterplot( x, y, hue=c, palette=cmap, ax=ax, legend="full", **scatter_kwargs ) ax.legend(loc=legend, ncol=unique_labels // 15) return fig, ax