2016-08-22 78 views
0

我想创建一个tsplot,其中x和y轴的长度相同。换句话说,图的宽高比应为1seaborn:如何制作tsplot正方形

这个DOS不行:

fig, ax = plt.subplots() 
fig.set_size_inches(2, 2) 
sns.tsplot(data=df, condition=' ', time='time', value='value', unit=' ', ax=ax) 

回答

4

你可以通过控制matplotlib对象的aspect 参数更改地块的长宽比如图所示:

import numpy as np 
import seaborn as sns 
import matplotlib.pyplot as plt 

np.random.seed(22) 
sns.set_style("whitegrid") 

gammas = sns.load_dataset("gammas") 
fig = plt.figure() 
ax = fig.add_subplot(111, aspect=2) #Use 'equal' to have the same scaling for x and y axes 
sns.tsplot(time="timepoint", value="BOLD signal", unit="subject", 
      condition="ROI", data=gammas, ax=ax) 
plt.tight_layout() 
plt.show() 

Image