简体   繁体   中英

How to create labels, y_axis in percentage, and grid lines

I'm trying to plot cumulative distribution for a dataset, I'm stuck at creating or changing y-axis to percentage and adding axis labels.

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt


st_cum = st_new[['sys_mod_count']]
#sort values per column
sorted_values = st_cum.apply(lambda x: x.sort_values())

#plot with matplotlib
#dimensions per variable.

for col in sorted_values.columns: 
    y = np.linspace(0.0,100.0, len(sorted_values[col].dropna()))    
    plt.plot(sorted_values[col].dropna(), y)

图形图

You can just add the following lines:

plt.xlabel("X")
plt.ylabel("Y") 
plt.grid(True) #Grid plotting
plt.axis('equal') #Space is equal in both axis
plt.show()

You can find more information here: matplotlib

In order to show the percentage, just write the percentage symbol in the ylabel

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM