JupyterNotebook 可視化技巧

import numpy as np
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

  • 格子

    sns.set_style("whitegrid")
    
  • svg顯示

    %config InlineBackend.figure_format = 'svg'
    
  • svg保存

    plt.savefig('%s.pdf'%file, bbox_inches='tight')
    
  • 中文

    plt.rcParams['font.sans-serif'] = ['SimHei']
    plt.rcParams['axes.unicode_minus'] = False
    
  • 3D座標系

    from mpl_toolkits.mplot3d import Axes3D
    fig = plt.figure()
    ax = Axes3D(fig)
    ax.scatter3D(xs,ys,zs,marker='.')
    
  • 可交互的3D視圖(由於某bug,所以%matplotlib notebook寫兩次)

    %matplotlib notebook
    %matplotlib notebook
    
    ax.scatter3D(xs,ys,zs,marker='.')
    
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章