我有这样的df:
bnw_Percent bnw_Value mtgp_Percent mtgp_Value php_Percent php_Value
0 0.004414 1.48150 0.010767 2.03548 0.028395 3.91826
1 0.015450 5.44825 0.020337 6.01205 0.352093 7.77627
2 0.059593 9.41501 0.043067 9.98863 1.118746 11.63430
3 0.156709 13.38180 0.137575 13.96520 1.164177 15.49230
4 0.355353 17.34850 0.242849 17.94180 1.436765 19.35030
5 0.560620 21.31530 0.436650 21.91840 1.635527 23.20830
6 0.896109 25.28200 0.695051 25.89490 1.839968 27.06630
7 1.436864 29.24880 1.208264 29.87150 2.169345 30.92430
8 2.145364 33.21550 2.025338 33.84810 3.219944 34.78230
9 3.412276 37.18230 3.423814 37.82470 4.514737 38.64030
10 5.566469 41.14910 5.351055 41.80120 6.542109 42.49830
11 9.188426 45.11580 8.220981 45.77780 9.233914 46.35640
12 14.300219 49.08260 12.081444 49.75440 12.010904 50.21440
13 18.072263 53.04930 16.622603 53.73100 13.833835 54.07240
14 19.641556 57.01610 20.070343 57.70750 13.788404 57.93040
15 14.682058 60.98280 16.976708 61.68410 12.715089 61.78840
16 7.237292 64.94960 9.493845 65.66070 9.489466 65.64640
17 2.057077 68.91640 2.672537 69.63730 4.100176 69.50440
18 0.211888 72.88310 0.265579 73.61380 0.800727 73.36240
19 0.000000 76.84990 0.001196 77.59040 0.005679 77.22040
我正在用以下代码制作一个情节:
plot=df.plot(x=['bnw_Value', 'mtgp_Value', 'php_Value'], y=['bnw_Percent', 'php_Percent', 'mtgp_Percent'], title='Frequency Distribution of Fuzzy Accumulated Values')
plot.set_xlabel('Value')
plot.set_ylabel('Percent')
plot.legend(loc='center left', bbox_to_anchor=(1, 0.5))
看起来像这样:
我的问题是这导致重叠的x轴值,我真正想要的是bnw_Value
,mtgp_Value
或php_Value
中的最小值和最大值在这三列中的任何一列中,以10为增量。或者至少x轴可以某种方式读取。
答案 0 :(得分:1)
你可以这样做:
df.plot(x=df[[col for col in df.columns if 'Value' in col]].min(axis=1),
y=['bnw_Percent', 'php_Percent', 'mtgp_Percent'],
title='Frequency Distribution of Fuzzy Accumulated Values')
说明:
In [24]: [col for col in df.columns if 'Value' in col]
Out[24]: ['bnw_Value', 'mtgp_Value', 'php_Value']
In [25]: df[[col for col in df.columns if 'Value' in col]].min(axis=1)
Out[25]:
0 1.48150
1 5.44825
2 9.41501
3 13.38180
4 17.34850
5 21.31530
6 25.28200
7 29.24880
8 33.21550
9 37.18230
10 41.14910
11 45.11580
12 49.08260
13 53.04930
14 57.01610
15 60.98280
16 64.94960
17 68.91640
18 72.88310
19 76.84990
dtype: float64
答案 1 :(得分:0)
添加轮换(例如20):
plot=df.plot(x=['bnw_Value', 'mtgp_Value', 'php_Value'],
y=['bnw_Percent', 'php_Percent', 'mtgp_Percent'],
rot=20,
title='Frequency Distribution of Fuzzy Accumulated Values')