我试图理解可以在 matplotlib radviz 中使用的关键字参数。我正在使用众所周知的鸢尾花数据集,以及下面的简单代码:
import pandas as pd
plt.xkcd()
iris = pd.read_csv("iris.csv")
pd.tools.plotting.radviz(iris, "name")
生成以下图表:
如何设置图表的维度 (x, y) 和标题?如何指定图例的位置? radviz 可以使用哪些其他参数(如果有的话)?
非常感谢您的帮助。
最佳答案
所有 pandas 绘图工具都有一个 ax
参数,您可以创建轴并传递给绘图函数:
fig = plt.figure( )
ax = fig.add_axes( [.05, .05, .9, .9], title='whatever title' )
pd.tools.plotting.radviz( iris, 'name', ax=ax )
然后如果你需要改变图例,你可以这样做:
ax.legend( loc='center right', fontsize='medium' )
或更改标题:
ax.set_title( 'new title' )
或者,我相信绘图工具会在绘图后返回轴,所以您可以这样做
ax = pd.tools.plotting.radviz( iris, 'name')
并检查 dir( ax )
以获得一些可用的功能。
with plt.xkcd( ):
ax = pd.tools.plotting.radviz(df, 'Name')
ax.legend( loc='center left', bbox_to_anchor=(0, 1),
fontsize='medium', fancybox=True, ncol=3 )
ax.set_xlim( -1.6, 1.6, emit=True, auto=False )
ax.set_title( 'iris - radviz', loc='right' )
关于matplotlib - matplotlib radviz 中的关键字参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20503818/