问题描述
我对熊猫 scatter_matrix 函数中' ax '关键字的含义感到困惑:
I'm puzzled by the meaning of the 'ax' keyword in the pandas scatter_matrix function:
pd.scatter_matrix(frame,alpha = 0.5,figsize = None, ax = None ,grid = False,对角线='hist',marker ='.',density_kwds = {},hist_kwds = {},** kwds)
pd.scatter_matrix(frame, alpha=0.5, figsize=None, ax=None, grid=False, diagonal='hist', marker='.', density_kwds={}, hist_kwds={}, **kwds)
文档字符串中有关ax关键字的唯一线索对我来说太神秘了:
The only clue given in the docstring for the ax keyword is too cryptic for me:
ax : Matplotlib axis object
我查看了scatter_matrix函数的熊猫代码,并将ax变量并入以下matplotlib子图调用中:
I had a look in the pandas code for the scatter_matrix function, and the ax variable is incorporated in the following matplotlib subplots call:
fig, axes = plt.subplots(nrows=n, ncols=n, figsize=figsize, ax=ax,
squeeze=False)
但是,对我而言,我在matplotlib子图中找不到对'ax'关键字的任何引用!
But, for the life of me, I can't find any reference to an 'ax' keyword in matplotlib subplots!
谁能告诉我这个ax关键字是干什么的??
Can anyone tell me what this ax keyword is for???
推荐答案
简而言之,它以网格内的子图为目标.
In short, it targets a subplot within a grid.
例如,如果具有nrows=2
和ncols=2
,则ax
允许您通过ax=axes[0,0]
(左上)或ax=axes[1,1]
(右下)等在特定轴上进行绘制.
If you have nrows=2
and ncols=2
, for example, then ax
allows you to plot on a specific axis by passing ax=axes[0,0]
(top left) or ax=axes[1,1]
(bottom right), etc.
创建子图时,您会收到一个axes
变量.您可以稍后使用该axes
变量的元素来绘制(或子绘制).
When you create the subplots, you receive an axes
variable. You can later plot (or subplot) with an element of that axes
variable as above.
查看此页面的定位不同的子图" 部分: http://pandas.pydata.org/pandas-docs/dev/visualization.html#targeting-different-subplots
我希望这会有所帮助.
这篇关于 pandas scatter_matrix函数中'ax'关键字的用途的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!