Here is a quick snippet for loading up all the taxonomic levels into a dictionary of pandas dataframes:
import pathlib
import tempfile
import qiime2
import pandas as pd
# Replace this with the filepath to your barplot viz.
# If you already have a viz in memory don't worry about
# saving and loading, just start with your barplot result.
taxa_barplot_fp = 'taxa-bar-plots.qzv'
taxa_barplot = qiime2.Visualization.load(taxa_barplot_fp)
csvs = dict()
with tempfile.TemporaryDirectory() as tmpdir:
# This method is on every QIIME 2 Visualization
taxa_barplot.export_data(tmpdir)
data_dir_fp = pathlib.Path(tmpdir)
csv_fps = sorted(data_dir_fp.glob('level-*csv'))
for csv_fp in csv_fps:
name = str(csv_fp.name)
csvs[name] = pd.read_csv(csv_fp, index_col='index')
The keys are 'level-1.csv', 'level-2.csv', ..., 'level-n.csv', and the values look like: