making matplotlib graphs look like R by default?

后端 未结 8 1730
自闭症患者
自闭症患者 2021-01-29 23:02

Is there a way to make matplotlib behave identically to R, or almost like R, in terms of plotting defaults? For example R treats its axes pretty differently from

8条回答
  •  借酒劲吻你
    2021-01-29 23:33

    matplotlib >= 1.4 suports styles (and ggplot-style is build in):

    In [1]: import matplotlib as mpl
    
    In [2]: import matplotlib.pyplot as plt
    
    In [3]: import numpy as np
    
    In [4]: mpl.style.available
    Out[4]: [u'dark_background', u'grayscale', u'ggplot']
    
    In [5]: mpl.style.use('ggplot')
    
    In [6]: plt.hist(np.random.randn(100000))
    Out[6]: 
    ...
    

    enter image description here

提交回复
热议问题