Seaborn plots not showing up

前端 未结 7 1520
暖寄归人
暖寄归人 2020-11-27 09:54

I\'m sure I\'m forgetting something very simple, but I cannot get certain plots to work with Seaborn.

If I do:

import seaborn as sns
7条回答
  •  离开以前
    2020-11-27 10:18

    Plots created using seaborn need to be displayed like ordinary matplotlib plots. This can be done using the

    plt.show()
    

    function from matplotlib.

    Originally I posted the solution to use the already imported matplotlib object from seaborn (sns.plt.show()) however this is considered to be a bad practice. Therefore, simply directly import the matplotlib.pyplot module and show your plots with

    import matplotlib.pyplot as plt
    plt.show()
    

    If the IPython notebook is used the inline backend can be invoked to remove the necessity of calling show after each plot. The respective magic is

    %matplotlib inline
    

提交回复
热议问题