本文整理汇总了Python中seaborn.set_color_codes方法的典型用法代码示例。如果您正苦于以下问题:Python seaborn.set_color_codes方法的具体用法?Python seaborn.set_color_codes怎么用?Python seaborn.set_color_codes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类seaborn
的用法示例。
在下文中一共展示了seaborn.set_color_codes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: barplot_messages_per_weekday
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import set_color_codes [as 别名]
def barplot_messages_per_weekday(msgs, your_name, target_name, path_to_save):
sns.set(style="whitegrid", palette="pastel")
messages_per_weekday = stools.get_messages_per_weekday(msgs)
labels = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
ax = sns.barplot(x=labels, y=[len(weekday) for weekday in messages_per_weekday.values()],
label=your_name, color="b")
sns.set_color_codes("muted")
sns.barplot(x=labels,
y=[len([msg for msg in weekday if msg.author == target_name])
for weekday in messages_per_weekday.values()],
label=target_name, color="b")
ax.legend(ncol=2, loc="lower right", frameon=True)
ax.set(ylabel="messages")
sns.despine(right=True, top=True)
fig = plt.gcf()
fig.set_size_inches(11, 8)
fig.savefig(os.path.join(path_to_save, barplot_messages_per_weekday.__name__ + ".png"), dpi=500)
# plt.show()
log_line(f"{barplot_messages_per_weekday.__name__} was created.")
plt.close("all")
示例2: generate_clusters
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import set_color_codes [as 别名]
def generate_clusters(words, vectors_in_2D, print_status=True):
# HDBSCAN, i.e. hierarchical density-based spatial clustering of applications with noise (https://github.com/lmcinnes/hdbscan)
vectors = vectors_in_2D
sns.set_context('poster')
sns.set_color_codes()
plot_kwds = {'alpha' : 0.5, 's' : 500, 'linewidths': 0}
clusters = HDBSCAN(min_cluster_size=2).fit_predict(vectors)
palette = sns.color_palette("husl", np.unique(clusters).max() + 1)
colors = [palette[cluster_index] if cluster_index >= 0 else (0.0, 0.0, 0.0) for cluster_index in clusters]
fig = plt.figure(figsize=(30, 30))
plt.scatter(vectors.T[0], vectors.T[1], c=colors, **plot_kwds)
plt.axis('off')
x_vals = [i[0] for i in vectors]
y_vals = [i[1] for i in vectors]
plt.ylim(min(y_vals)-0.3, max(y_vals)+0.3)
plt.xlim(min(x_vals)-0.3, max(x_vals)+0.3)
font_path = getcwd() + '/fonts/Comfortaa-Regular.ttf'
font_property = matplotlib.font_manager.FontProperties(fname=font_path, size=24)
for i, word in enumerate(words):
if type(word) != type(None):
if type(word) != type(""):
word = unidecode(word).replace("_", " ")
else:
word = word.replace("_", " ")
text_object = plt.annotate(word, xy=(x_vals[i], y_vals[i]+0.05), font_properties=font_property, color=colors[i], ha="center")
plt.subplots_adjust(left=(500/3000), right=(2900/3000), top=1.0, bottom=(300/2700))
plt.savefig(get_visualization_file_path(print_status), bbox_inches="tight")
return clusters
示例3: model_ranks
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import set_color_codes [as 别名]
def model_ranks(self):
"""
Plot ranking among accuracy offered by various models based on our datasets.
"""
plt.xlabel('Accuracy')
plt.title('Classifier Accuracy')
sns.set_color_codes("muted")
sns.barplot(x='Accuracy', y='Classifier', data=Base.model_ranking, color="b");