I’ve been facing the problem which is not able to check two box plot in one figure in python. (Dataframes of the two box are different as well.)
I do not know the reason of this problem, even though I’ve tried to check the dataframes, and the range of the data.
Here’s what I can tell you guys.
cluster_data = df_encoded[df_encoded['dbscan_cluster'] != -1]
cluster_data.info()
<class 'pandas.core.frame.DataFrame'>
Index: 1085 entries, 0 to 1204
Data columns (total 17 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 본사정원수 1085 non-null float64
1 본사휴가자수 1085 non-null float64
2 본사출장자수 1085 non-null float64
3 본사시간외근무명령서승인건수 1085 non-null float64
4 현본사소속재택근무자수 1085 non-null float64
5 중식계 1085 non-null float64
6 석식계 1085 non-null float64
7 month 1085 non-null float64
8 요일_금 1085 non-null bool
9 요일_목 1085 non-null bool
10 요일_수 1085 non-null bool
11 요일_월 1085 non-null bool
12 요일_화 1085 non-null bool
13 조식메뉴_Main_encoded 1085 non-null int64
14 중식메뉴_Main_encoded 1085 non-null int64
15 석식메뉴_Main_encoded 1085 non-null int64
16 dbscan_cluster 1085 non-null int64
dtypes: bool(5), float64(8), int64(4)
memory usage: 115.5 KB
noise_data.info()
<class 'pandas.core.frame.DataFrame'>
Index: 77 entries, 2 to 994
Data columns (total 17 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 본사정원수 77 non-null float64
1 본사휴가자수 77 non-null float64
2 본사출장자수 77 non-null float64
3 본사시간외근무명령서승인건수 77 non-null float64
4 현본사소속재택근무자수 77 non-null float64
5 중식계 77 non-null float64
6 석식계 77 non-null float64
7 month 77 non-null float64
8 요일_금 77 non-null bool
9 요일_목 77 non-null bool
10 요일_수 77 non-null bool
11 요일_월 77 non-null bool
12 요일_화 77 non-null bool
13 조식메뉴_Main_encoded 77 non-null int64
14 중식메뉴_Main_encoded 77 non-null int64
15 석식메뉴_Main_encoded 77 non-null int64
16 dbscan_cluster 77 non-null int64
dtypes: bool(5), float64(8), int64(4)
memory usage: 8.2 KB
min(cluster_data['중식계']), max(cluster_data['중식계'])
(0.0, 1.0)
cluster_data['중식계'].unique()
array([0.638865 , 0.49097163, 0.58641445, 0.54084265, 0.52708512,
0.83576956, 0.61736887, 0.53310404, 0.52794497, 0.40154772,
0.86156492, 0.51848667, 0.62424764, 0.53396389, 0.40412726,
0.49269132, 0.71453138, 0.46517627, 0.88564058, 0.62768702,
0.52020636, 0.47377472, 0.37145314, 0.85124678, 0.56921754,
0.60361135, 0.46087704, 0.39638865, 0.6311264 , 0.57351677,
0.49871023, 0.48581255, 0.77128117, 0.51246776, 0.41702494,
0.31384351, 0.80911436, 0.4677558 , 0.47893379, 0.40240757,
0.79879622, 0.40842648, 0.57867584, 0.70851247, 0.58813414,
0.47549441, 0.55374033, 0.34565778, 0.80051591, 0.42906277,
0.62940671, 0.44282029, 0.3061049 , 0.81341359, 0.57437661,
0.36715391, 0.79105761, 0.6122098 , 0.5322442 , 0.39294927,
0.39982803, 0.76010318, 0.48151333, 0.51762683, 0.30696475,
0.74290628, 0.69733448, 0.55202064, 0.41874463, 0.31298366,
0.80395529, 0.53740327, 0.47635426, 0.36543422, 0.81513328,
0.54600172, 0.45829751, 0.34479794, 0.81427343, 0.59157352,
0.43336199, 0.3422184 , 0.73086844, 0.68357696, 0.49957008,
0.43766122, 0.72742906, 0.4505589 , 0.50730868, 0.50128977,
0.85640585, 0.56405847, 0.55288048, 0.48237317, 0.48753224,
0.70421324, 0.53568358, 0.49011178, 0.74118659, 0.50902837,
0.47119518, 0.37575236, 0.67927773, 0.54256234, 0.49527085,
0.44711952, 0.32244196, 0.65262253, 0.43508169, 0.2966466 ,
0.63800516, 0.49699054, 0.46947549, 0.47205503, 0.35425623,
0.5399828 , 0.55631986, 0.39380911, 0.83404987, 0.7300086 ,
0.55460017, 0.50644884, 0.44453998, 0.82717111, 0.56491831,
0.74634566, 0.41960447, 0.54170249, 0.3972485 , 0.33190026,
0.8383491 , 0.66380052, 0.51160791, 0.361135 , 0.76440241,
0.63370593, 0.71539123, 0.64316423, 0.47033534, 0.83061049,
0.89423904, 0.56319862, 0.64918315, 0.77386071, 0.60017197,
0.54772141, 0.42218401, 0.39896819, 0.75236457, 0.47979364,
0.43938091, 0.37403267, 0.79793637, 0.68013758, 0.61049011,
0.48839209, 0.43594153, 0.7394669 , 0.59329321, 0.53654342,
0.8288908 , 0.53138435, 0.5038693 , 0.37317283, 0.80739467,
0.64488392, 0.49355116, 0.36457438, 0.81685297, 0.51934652,
0.56749785, 0.69991402, 0.54514187, 0.51504729, 0.2794497 ,
0.66466036, 0.40756664, 0.5227859 , 0.34651763, 0.79019776,
0.42476354, 0.19604471, 0.22699914, 0.77042132, 0.45313844,
0.35683577, 0.31126397, 0.84006879, 0.64058469, 0.56147893,
0.60533104, 0.45915735, 0.8822012 , 0.76526225, 0.58469475,
0.63542562, 0.35511608, 0.73602752, 0.58297506, 0.8116939 ,
0.60963027, 0.87962167, 0.7033534 , 0.43078246, 0.9183147 ,
0.6027515 , 0.57781599, 0.60877042, 0.72656922, 0.65434222,
0.87274291, 0.56577816, 0.31642304, 0.85898538, 0.58125537,
0.57179708, 0.28288908, 0.88736028, 0.52880482, 0.29922614,
0.57953568, 0.5760963 , 0.29492691, 0.4411006 , 0.65692175,
0.51676698, 0.26311264, 0.7927773 , 0.5133276 , 0.21066208,
0.46689596, 0.49441101, 0.35855546, 0.21582115, 0.69905417,
0.42562339, 0.42304385, 0.23989682, 0.19690456, 0.07480653,
0.42648323, 0.44797936, 0.77987962, 0.51074807, 0.42992261,
0.31470335, 0.783319 , 0.50988822, 0.47807395, 0.46603611,
0.25881341, 0.45141874, 0.72570937, 0.71367154, 0.58985383,
0.49785039, 0.26913156, 0.73172829, 0.58211522, 0.44539983,
0.34307825, 0.57265692, 0.52966466, 0.27257094, 0.67755804,
0.53482373, 0.74978504, 0.39036973, 0.30266552, 0.70765262,
0.45657782, 0.43680138, 0.17626827, 0.55803955, 0.38607051,
0.43250215, 0.31986242, 0.5588994 , 0.41358555, 0.35597592,
0.34049871, 0.80481513, 0.65090284, 0.25623388, 0.76956148,
0.53826311, 0.90627687, 0.59931212, 0.48495271, 0.78933792,
0.37747206, 0.69045572, 0.52106621, 0.25193465, 0.59587274,
0.75408426, 0.47463457, 0.20378332, 0.45399828, 0.73430782,
0.56663801, 0.44625967, 0.74892519, 0.41616509, 0.28718831,
0.61994841, 0.3783319 , 0.29578676, 0.22957868, 0.66122098,
0.38177128, 0.7472055 , 0.50558899, 0.27687016, 0.73344798,
0.36027515, 0.23129837, 0.01289768, 0.08426483, 0.73258813,
0.50472915, 0.40068788, 0.75838349, 0.48925193, 0.32932072,
0.82545142, 0.30782459, 0.81255374, 0.36629407, 0.9638865 ,
0.65176268, 0.60705073, 0.92519347, 0.67841788, 0.36801376,
0.82115219, 0.69561479, 0.5950129 , 0.30524506, 0.54858126,
0.18228719, 0.9105761 , 0.62252794, 0.91573517, 0.56061909,
0.35339639, 0.74204643, 0.6844368 , 0.39810834, 0.84264832,
0.55030095, 0.27515047, 0.78761823, 0.52192605, 0.38263113,
0.84866724, 0.48065348, 0.77300086, 0.47291488, 0.26569218,
0.3250215 , 0.28632846, 0.72312984, 0.8022356 , 0.21238177,
0.86844368, 0.30352537, 0.78675838, 0.28804815, 0.80137575,
0.52364574, 0.22012038, 0.61564918, 0.18142734, 0.58383491,
0.68873603, 0.24849527, 0.6577816 , 0.70507309, 0.38865004,
0.16595013, 0.59759243, 0.35941531, 0.20980224, 0.41014617,
0.51590714, 0.216681 , 0.40928633, 0.4239037 , 0.30094583,
0.77644024, 0.46345658, 0.32846088, 0.79535684, 0.4961307 ,
0.78847807, 0.24505589, 0.72914875, 0.57093723, 0.09372313,
0.76784179, 0.54428203, 0.28030954, 0.54342218, 0.28460877,
0.7566638 , 0.54686156, 0.34995701, 0.20894239, 0.68099742,
0.17196905, 0.73774721, 0.3877902 , 0.71195185, 0.36285469,
0.19862425, 0.67153912, 0.42820292, 0.81857266, 0.40326741,
0.77815993, 0.75150473, 0.13757524, 0. , 0.1900258 ,
0.16766982, 0.03095443, 0.48323302, 0.6672399 , 0.4144454 ,
0.4049871 , 0.74548581, 0.62338779, 0.83748925, 0.31900258,
1. , 0.69303525, 0.87532244, 0.65004299, 0.86242476,
0.84092863, 0.3155632 , 0.84350817, 0.82975064, 0.59673259,
0.23301806, 0.44196045, 0.15907137, 0.63026655, 0.22098022,
0.76354256, 0.3327601 , 0.34909716, 0.23731728, 0.26741187,
0.70077386, 0.09630267, 0.75494411, 0.4600172 , 0.79363715,
0.46431642, 0.07996561, 0.20808255, 0.17970765, 0.41186586,
0.44024076, 0.20550301, 0.75580396, 0.21496131, 0.59243336,
0.4866724 , 0.37661221, 0.61650903, 0.38521066, 0.14273431,
0.12381771, 0.46861565, 0.66809974, 0.14617369, 0.8194325 ,
0.53912296, 0.50214961, 0.2605331 , 0.91745486, 0.55717971,
0.40670679, 0.33619948, 0.44368014, 0.61392949, 0.34823732,
0.81083405, 0.27858985, 0.71969046, 0.23215821, 0.68271711,
0.42046432, 0.3516767 , 0.24935512, 0.34737747, 0.67325881,
0.32760103, 0.63284609, 0.21926053, 0.41530525, 0.38349097,
0.6938951 , 0.38091144, 0.07824592, 0.29148753, 0.23817713,
0.28976784, 0.34393809, 0.66981943, 0.49183147, 0.41788478,
0.33447979, 0.64144454, 0.28116939, 0.6749785 , 0.29320722,
0.80567498, 0.46259673, 0.41272571, 0.92347377, 0.45571797,
0.84780739, 0.8099742 , 0.91659501, 0.66895959, 0.6044712 ,
0.29750645, 0.6216681 , 0.57695615, 0.25537403, 0.84952709,
0.67669819, 0.48409286, 0.61306965, 0.74376612, 0.55975924,
0.68185727, 0.79707653, 0.33018057, 0.17884781, 0.82373173,
0.57007739, 0.42734308, 0.27343078, 0.5494411 , 0.18572657,
0.65864144, 0.35081685, 0.13241617, 0.34135856, 0.31040413,
0.71711092, 0.36371453, 0.18916595, 0.32588134, 0.71883061,
0.36199484, 0.27085125, 0.58039553, 0.30954428, 0.76870163,
0.70679278, 0.15563199, 0.15477214, 0.61478934, 0.43422184,
0.38950989, 0.18744626, 0.38693035, 0.57523646, 0.50300946,
0.23559759, 0.52622528, 0.0533104 , 0.82201204, 0.5855546 ,
0.68787618, 0.4772141 , 0.50816853, 0.08770421, 0.25795357,
0.14015477, 0.67067928, 0.20034394, 0.41100602, 0.63456578,
0.88392089, 0.76698194, 0.65606191, 0.87790198, 0.72398968,
0.88822012, 0.77901978, 0.72141015, 0.40584695, 0.25365434,
0.95356836, 0.63972485, 0.36973345, 0.82631126, 0.53052451,
0.68529665, 0.2433362 , 0.61822872])
min(noise_data['중식계']), max(noise_data['중식계'])
(0.1994840928632846, 0.879621668099742)
I think there is no problem on my two dataframes.
fig, axes = plt.subplots(1, 2, figsize=(16, 8), sharey=True)
# 중식계 박스플롯
sns.boxplot(data=[noise_data['중식계'], cluster_data['중식계']], notch=True, palette="Set2", ax=axes[0])
axes[0].set_title('중식계 분포 : Noise vs Cluster')
axes[0].set_xticklabels(['Noise', 'Cluster'])
# 석식계 박스플롯
sns.boxplot(data=[noise_data['석식계'], cluster_data['석식계']], notch=True, palette="Set2", ax=axes[1])
axes[1].set_title('석식계 분포 : Noise vs Cluster')
axes[1].set_xticklabels(['Noise', 'Cluster'])
plt.show()
As long as i use this codes for visualization, it is supposed to have two subplots by one figure(noise plot and cluster plot in left subplot, same to right subplot). There is only one noise plot by each subplot though.
It’s really hard to figure out the reason!!! Please help me solve this one.