Change the name of the factor plot in the marine

Does anyone know how to change the legend and title in the sea? See below. I would like to change the name of "Gauss" to "Guassian Naive Bayes", etc. enter image description here
enter image description here or legend in the second image

+6
source share
1 answer

These values ​​are simply taken from the input DataFrame field, which you use as the col or hue variable in the factorgrid graph. Therefore, it would be correct to set the values ​​as you want in the original DataFrame, and then pass this to seaborn.factorplot .

Alternatively, once you have plotted, the function returns an object of the FacetGrid class, which has a method called set_titles . This allows you to change the names after more flexible plotting, but also based on the values ​​in the DataFrame that you passed to the function. See the documentation for this method for more information.

The final option is to set the headers manually using the matplotlib commands. The returned FacetGrid also has an axes attribute, which is a two-dimensional array of maptlotlib axes in the figure. You can go through this and set the headers to whatever you want:

 g = sns.factorplot(...) titles = ["foo", "bar", "buz"] for ax, title in zip(g.axes.flat, titles): ax.set_title(title) 
+12
source

Source: https://habr.com/ru/post/972344/


All Articles