使大 pandas plot()显示xlabel和xvalues [英] Make pandas plot() show xlabel and xvalues

查看:91
本文介绍了使大 pandas plot()显示xlabel和xvalues的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用标准的pandas.df.plot()函数在数据框中绘制两列.由于某些原因,x轴值和xlabel不可见!似乎也没有在功能中将其打开的选项(请参见

I am using the standard pandas.df.plot() function to plot two columns in a dataframe. For some reason, the x-axis values and the xlabel are not visible! There seem to be no options to turn them on in the function either (see https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.plot.html).

有人知道发生了什么事,以及如何纠正它吗?

Does someone know what is going on, and how to correct it?

import matplotlib.cm as cm
import pandas as pd

ax1 = df.plot.scatter(x='t', y='hlReference', c='STEP_STRENGTH', cmap=cm.autumn);

给出以下内容:

推荐答案

首先创建轴实例,然后将其作为参数发送到plot()

Create your axes instance first and then send it as an argument to the plot()

import matplotlib.cm as cm
import pandas as pd


X = np.random.rand(10,3)
df = pd.DataFrame(X,columns=['t','hlReference', 'STEP_STRENGTH'])
fig,ax1=plt.subplots()
df.plot.scatter(x='t', y='hlReference', c='STEP_STRENGTH', cmap=cm.autumn,ax=ax1)

这篇关于使大 pandas plot()显示xlabel和xvalues的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆