Python Matplotlib如何更改matshow的figsize
如何更改jupyter笔记本中的figsize 例如,此代码更改图形大小Python Matplotlib如何更改matshow的figsize,python,pandas,matplotlib,Python,Pandas,Matplotlib,如何更改jupyter笔记本中的figsize 例如,此代码更改图形大小 %matplotlib inline import matplotlib.pyplot as plt import pandas as pd d = pd.DataFrame({'one' : [1, 2, 3, 4, 5], 'two' : [4, 3, 2, 1, 5]}) plt.figure(figsize=(10,5)) plt.plot(d.one, d.two) 但下面
%matplotlib inline
import matplotlib.pyplot as plt
import pandas as pd
d = pd.DataFrame({'one' : [1, 2, 3, 4, 5],
'two' : [4, 3, 2, 1, 5]})
plt.figure(figsize=(10,5))
plt.plot(d.one, d.two)
但下面的代码不起作用
%matplotlib inline
import matplotlib.pyplot as plt
import pandas as pd
d = pd.DataFrame({'one' : [1, 2, 3, 4, 5],
'two' : [4, 3, 2, 1, 5]})
plt.figure(figsize=(10,5))
plt.matshow(d.corr())
默认情况下,
plt.matshow()
生成自己的地物,因此结合plt.figure()
将创建两个地物,主持matshow绘图的地物不是具有figsize集的地物
有两种选择:
fignum
参数
plt.figure(figsize=(10,5))
plt.matshow(d.corr(), fignum=1)
matplotlib.axes.axes.matshow而不是pyplot.matshow
绘制matshow
fig, ax = plt.subplots(figsize=(10,5))
ax.matshow(d.corr())
通过@ImportanceOfBeingErnest改进解决方案
matfig = plt.figure(figsize=(8,8))
plt.matshow(d.corr(), fignum=matfig.number)
这样,您就不需要跟踪数字了。解决方案对我不起作用,但我找到了另一种方法:
plt.图(figsize=(10,5))
plt.matshow(d.corr(),fignum=1,aspect='auto')
太棒了!plt.figure(figsize=(10,5))plt.matshow(d.corr(),fignum=1)