Python seaborn.set_color_codes() Examples
The following are 3
code examples of seaborn.set_color_codes().
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
seaborn
, or try the search function
.
Example #1
Source File: plotter.py From message-analyser with MIT License | 6 votes |
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")
Example #2
Source File: words2map.py From words2map with MIT License | 5 votes |
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
Example #3
Source File: plot.py From speedml with MIT License | 5 votes |
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");