amn*_*n41 21 python matplotlib seaborn
在进行散点图时,如何获得seaborn颜色?
import matplotlib.pyplot as plt
import seaborn as sns
ax=fig.add_subplot(111)
for f in files:
ax.scatter(args) # all datasets end up same colour
#plt.plot(args) # cycles through palette correctly
Run Code Online (Sandbox Code Playgroud)
Car*_*ten 42
你必须告诉matplotlib使用哪种颜色.例如,使用seaborn的默认调色板:
import matplotlib.pyplot as plt
import seaborn as sns
import itertools
ax=fig.add_subplot(111)
palette = itertools.cycle(sns.color_palette())
for f in files:
ax.scatter(args, color=next(palette))
Run Code Online (Sandbox Code Playgroud)
在itertools.cycle
确保我们不会跑出来的颜色,并使用最后一个后再次以第一个开始.
归档时间: |
|
查看次数: |
9633 次 |
最近记录: |