code:df.boxplot()
如预期的那样,它返回了数据框中所有列的图表。但同时也返回了一些文本。例如:
{'boxes': [<matplotlib.lines.Line2D at 0x118efc278>,<matplotlib.lines.Line2D at 0x118f0c668>,<matplotlib.lines.Line2D at 0x118f20f98>,<matplotlib.lines.Line2D at 0x11d58e908>,<matplotlib.lines.Line2D at 0x11d5a6278>,<matplotlib.lines.Line2D at 0x11d5b7ba8>,}
有没有办法去除这些文本?另外,如果有关于如何定制图表以突出显示异常值的建议,将会非常有帮助。提前感谢!
回答:
正如@Greg上面所说,这是一个函数的返回值。
我猜你是使用Jupyter/IPython笔记本来进行内联绘图,所以你不需要实际调用plt.show()
。
虽然你可以使用a = df.boxplot()
或者甚至只是df.boxplot();
,但我建议你养成使用plt.show()
的习惯,这样以后如果你想在内联jupyter会话之外的其他地方执行你的代码,就可以这样做。