-
Notifications
You must be signed in to change notification settings - Fork 0
/
seaborn_violin_SAAVs.py
28 lines (21 loc) · 1.21 KB
/
seaborn_violin_SAAVs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
#read in the data file from an excel spreadsheet
data=pd.read_csv("methanococci_SAAVs-SNVs.txt",sep='\t')
#I will do one for Piccard and one for Von Damm
#use seaborn to make the violin lot
sns.set_style("ticks") #no grids, just ticks
sns.despine(trim=True) #removes the top and side lines in the graph so it's just the x and y axis lines drawn
sns.set_context("paper", font_scale=1.50) #made it suitable for publishing a paper and also changes the font size
sns.set_color_codes()
fig = plt.figure(figsize=(10,10)) #i think this adjusts the size
ax = fig.add_subplot(1,1,1) #no idea what this does but i think it's related to the line above
#now actually load the data
ax = sns.violinplot(y="SAAV/SNV Ratio", x="Vent Field", data=data, scale="width")
ax.tick_params(labelsize=15) #makes the font smaller on the x axis
locs, labels = plt.xticks() #this and the next line make the labels rotate 45 degrees
plt.setp(labels, rotation=30)
plt.savefig('methanococci_SAAVs-SNVs.pdf')
#http://stackoverflow.com/questions/31063005/how-to-widen-boxes-in-seaborn-boxplot
#reason why "hue" didn't work. still confused, and i wound up just doing it in illustrator.