Home > Mobile >  Adjust y axis when using parallel_coordinates
Adjust y axis when using parallel_coordinates

Time:02-05

I'm working on plotting some data with pandas in the form of parallel coordinates, and I'm not too sure how to go about setting the y-axis scaling.

here is my code:

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()

and I got this: enter image description here

as shown in the graph, the value of "tempo" is way more than others. I want to scale all features values between 0 and 1 and get a line chart. How could I do that? Also, I want to change exegesis to vertical that readers can understand it easier.

this is my data frame: enter image description here

Thanks

CodePudding user response:

To normalize your values between 0 and 1, you have multiple choices. One of them could be (MinMaxScaler): the lowest value of each column is 0 and the highest value is 1:

df = (df - df.min()) / (df.max() - df.min())

To have vertically labels, use df.plot(rot=90)

  •  Tags:  
  • Related