使用 parallel_coordinates 时调整 y 轴
Adjust y axis when using parallel_coordinates
我正在用 pandas 以平行坐标的形式绘制一些数据,但我不太确定如何设置 y 轴缩放比例。
这是我的代码:
def show_means(df: pd.DataFrame):
plt.figure('9D-parallel_coordinates')
plt.title('continents & features')
parallel_coordinates(df,'continent', color=['blue', 'green', 'red', 'yellow','orange','black'])
plt.show()
我得到了这个:
enter image description here
如图所示,“tempo”的值远远超过其他。我想缩放 0 到 1 之间的所有特征值并获得折线图。我怎么能那样做?另外,我想把注解改成纵向的,这样读者更容易理解。
这是我的数据框:
enter image description here
谢谢
要将您的值归一化在 0 和 1 之间,您有多种选择。其中之一可能是(MinMaxScaler):每列的最低值为0,最高值为1:
df = (df - df.min()) / (df.max() - df.min())
要有垂直标签,使用df.plot(rot=90)
我正在用 pandas 以平行坐标的形式绘制一些数据,但我不太确定如何设置 y 轴缩放比例。
这是我的代码:
def show_means(df: pd.DataFrame):
plt.figure('9D-parallel_coordinates')
plt.title('continents & features')
parallel_coordinates(df,'continent', color=['blue', 'green', 'red', 'yellow','orange','black'])
plt.show()
我得到了这个: enter image description here
如图所示,“tempo”的值远远超过其他。我想缩放 0 到 1 之间的所有特征值并获得折线图。我怎么能那样做?另外,我想把注解改成纵向的,这样读者更容易理解。
这是我的数据框: enter image description here
谢谢
要将您的值归一化在 0 和 1 之间,您有多种选择。其中之一可能是(MinMaxScaler):每列的最低值为0,最高值为1:
df = (df - df.min()) / (df.max() - df.min())
要有垂直标签,使用df.plot(rot=90)