Ось Matplotlib для FacetGrid - PullRequest
0 голосов
/ 30 мая 2020

Почему https://seaborn.pydata.org/generated/seaborn.FacetGrid.html

не имеет аргумента ax, который принимает ось matplotlib, как другие графики

например, https://seaborn.pydata.org/generated/seaborn.distplot.html ?

Так как мне нужно установить ось matplotlib для FacetGrid, чтобы настроить индивидуальный стиль.

1 Ответ

1 голос
/ 30 мая 2020

FaceGrid создает сетку, поэтому вы не можете передать ей сетку. Отдельные графики хранятся внутри, и ими можно управлять, как в приведенном ниже коде.

import seaborn as sns
import pandas as pd

#dummy data
data= pd.DataFrame(data={'a':np.random.randint(0,2, 100),
                         'b':np.random.rand(100),
                         'c':np.random.rand(100)})

# make facetgrid and store in variable
g = sns.FacetGrid(data, col='a') # make facetgrid with 2 columns, because there are two distinct values in column a of data
g.map(plt.scatter, 'b', 'c') # map function to grid

# the individual axes of the grid are stored in g.
# you can access and edit them like so:

for ax in g.axes[0]:
    ax.set_ylabel('test')
    ax.set_ylim(0,1.5)
    ax.set_title('title')

enter image description here

...