EDIT: Removed old question to make it easier to find solution in post.
Seaborn is a Python data visualization library based on matplotlib. To use Seaborn, your data need to be in the tidy format.
You can use Pandas DataFrame.loc[] to filter a dataframe.
In the following example I will (1) load some data from an CSV file into a dataframe, (2) filter that data based on specific values in a column, (3) present that data in a boxplot using Seaborn, and (4) decide the order in which the data is presented and what labels should be used.
Some example data
Object,Metric,Score
M11,B2A10,2.7939033333333336
MT1,B2A10,1.287634388888889
MT1,B2A1,7.1535
MT1,B2A2,2.2441833333333334
MT1,B2A3,3.3787333333333334
MT1,B2A4,2.50297
MT1,B2A5,1.4254989999999998
MT1,B2A6,2.91325
MT1,B2A7,1.24806
MT1,B2A8,2.08797725
MT1,B2A9,1.208722
Import libraries and modules
import pandas as pd
import seaborn as sns
Set seaborn style
sns.set(style="whitegrid", palette="colorblind")
Load data and generate a list of items we want to filter
data = pd.read_csv("data.csv")
list = ["B2A10", "B2A1"]
Filter data using .loc and place into new dataframe
filtered_data = data.loc[data['Metric'].isin(list)]
Generate a boxplot using the filtered data
fig, ax = plt.subplots(figsize=(10,6))
ax = sns.boxplot(x='Metric', y='Length', data=samples, order=["B2A1", "B2A10"])
ax = sns.swarmplot(x="Metric", y="Length", data=samples, color=".25", order=["B2A1", "B2A10"])
ax.set_xlabel('Label X-Axis')
ax.set_ylabel('Label Y-Axis')
plt.title('Title',fontsize=16)
labels = [item.get_text() for item in ax.get_xticklabels()]
labels[0] = 'Sample 1'
labels[1] = 'Sample 2'
ax.set_xticklabels(labels)
plt.savefig('test.png', dpi=300, bbox_inches='tight')
The final graph should look like this.
