0
我遵循here的设置使matplotlib/seaborn可用于在Zeppelin中显示。然而,用下面的代码:Seaborn为不同的运行显示不同的颜色
%python
import seaborn as sns
import matplotlib
import numpy as np
matplotlib.use('Agg')
import matplotlib.pyplot as plt
plt.rcdefaults()
import StringIO
def show(p):
img = StringIO.StringIO()
p.savefig(img, format='svg')
img.seek(0)
print "%html <div style='width:600px'>" + img.buf + "</div>"
""" Prepare your plot here ... """
# Use the custom show function instead of plt.show()
x = np.random.randn(100)
ax = sns.distplot(x)
show(sns.plt)
奇怪的是,所显示的图中示出了所希望的颜色lightblue第一次运行该代码,但将显示不同的颜色,如果我执行相同的一段代码。有没有办法强制seaborn保持不变的颜色显示?谢谢。
你引用的例子看起来很混乱。为什么它将'matplotlib.pyplot'(一个模块)作为参数传递给'show()'函数?我建议以这种不同的方式。 – mwaskom