Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 熊猫图中的标签大小(散点矩阵)_Python_Pandas - Fatal编程技术网

Python 熊猫图中的标签大小(散点矩阵)

Python 熊猫图中的标签大小(散点矩阵),python,pandas,Python,Pandas,如何设置熊猫图中的标签大小 在正常绘图中,我做plt.xlabel('a',size=20) In [76]: from pandas.tools.plotting import scatter_matrix In [77]: df = DataFrame(randn(1000, 4), columns=['a', 'b', 'c', 'd']) In [78]: scatter_matrix(df, alpha=0.2, figsize=(6, 6), diagonal='kde') Ou

如何设置熊猫图中的标签大小

在正常绘图中,我做
plt.xlabel('a',size=20)

In [76]: from pandas.tools.plotting import scatter_matrix

In [77]: df = DataFrame(randn(1000, 4), columns=['a', 'b', 'c', 'd'])

In [78]: scatter_matrix(df, alpha=0.2, figsize=(6, 6), diagonal='kde')
Out[78]: 
array([[<matplotlib.axes._subplots.AxesSubplot object at 0x9f39e44c>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x9f39842c>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x9f383fcc>,
        <matplotlib.axes._subplots.AxesSubplot object at 0xa58039cc>],
       [<matplotlib.axes._subplots.AxesSubplot object at 0xa57f19ec>,
        <matplotlib.axes._subplots.AxesSubplot object at 0xa578e66c>,
        <matplotlib.axes._subplots.AxesSubplot object at 0xa5adb28c>,
        <matplotlib.axes._subplots.AxesSubplot object at 0xa5a9deec>],
       [<matplotlib.axes._subplots.AxesSubplot object at 0xa5d67fec>,
        <matplotlib.axes._subplots.AxesSubplot object at 0xa5dc764c>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x9fdb354c>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x9e63756c>],
       [<matplotlib.axes._subplots.AxesSubplot object at 0xa5d9ccac>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x9f6d1ecc>,
        <matplotlib.axes._subplots.AxesSubplot object at 0xa5d6f02c>,
        <matplotlib.axes._subplots.AxesSubplot object at 0xa5848e0c>]], dtype=object)
[76]中的
:来自pandas.tools.plotting导入散点矩阵
在[77]中:df=DataFrame(randn(1000,4),columns=['a','b','c','d'])
在[78]中:散射矩阵(df,alpha=0.2,figsize=(6,6),diagonal='kde')
出[78]:
数组([,,
,
,
],
[,
,
,
],
[,
,
,
],
[,
,
,
]],dtype=object)

散点矩阵()的返回是一个轴数,因此,没有简单的方法可以一次性设置字体大小(除了使用
plt.rcParam
覆盖它,例如
plt.rcParams['axes.labelsize']=20以更改标签大小),并且必须逐个设置,例如:
plt.setp(axes[0,0].yaxis.get_majorticklabels(),'size',15)

若要更改所有记号标签,请假设轴=散点矩阵(df,alpha=0.2,figsize=(6,6),对角线=kde')


pandas.tools.plotting在新版本中不推荐使用

如果您尝试:

来自pandas.tools.plotting导入散布矩阵

您将得到以下错误:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-9-d908f18459b1> in <module>
----> 1 from pandas.tools.plotting import scatter_matrix

ModuleNotFoundError: No module named 'pandas.tools'

您能提供完整的代码吗?我对matplotlib的了解有限
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-9-d908f18459b1> in <module>
----> 1 from pandas.tools.plotting import scatter_matrix

ModuleNotFoundError: No module named 'pandas.tools'
import pandas as pd
import matplotlib.pyplot as plt
from   numpy.random import randn

df = pd.DataFrame(randn(1000, 4), columns=['a', 'b', 'c', 'd'])

Axes = pd.plotting.scatter_matrix(df, alpha=0.2, figsize=(6, 6), diagonal='kde')

#y ticklabels
[plt.setp(item.yaxis.get_majorticklabels(), 'size', 15) for item in Axes.ravel()]
#x ticklabels
[plt.setp(item.xaxis.get_majorticklabels(), 'size', 5) for item in Axes.ravel()]
#y labels
[plt.setp(item.yaxis.get_label(), 'size', 20) for item in Axes.ravel()]
#x labels
[plt.setp(item.xaxis.get_label(), 'size', 3) for item in Axes.ravel()];