我有以下图表,现在我希望标签的固定顺序从小到大,但是pandas会重新排列它们以获得漂亮的图形。我想要它修复,以便更容易并排比较多个图形。
这是我使用的代码:
def faultDistributionPlotSaveToDisk(key):
sample_cut = pd.cut(freq_sample[key], bins=[1,10,100, 1000 ,100000], labels=["(1-10]", "(10-100]", "(100-1000]", "(1000-max]"])
plot = sample_cut.value_counts(normalize=True).plot()
fig = plot.get_figure()
fig.savefig(key + ".png")
答案 0 :(得分:2)
您可以将#quoteDIV{
margin-top: 5%;
}
#quote{
text-align: center;
color:white;
/*opacity: 0.9;*/
font-family: 'Titillium Web', sans-serif;
font-size: 21px;
}
#by{
text-align: center;
color: white;
/*opacity: 0.9;*/
font-family: 'Titillium Web', sans-serif;
font-size: 21px;
margin-top:-13px;
}
#greet{
color: white;
text-align: center;
font-size: 60px;
margin-top: 32%; /*PROBLEM!*/
/*opacity: 0.9;*/
font-family: 'Titillium Web', sans-serif;
}
#clock {
width: 5em;
height: 1.3em;
border-radius: 1em;
position: absolute;
left: 0; right: 0; top: 0; bottom: 0;
margin: auto;
font-family: 'Titillium Web', sans-serif;
text-align: center;
font-size: 118px;
color: white;
/*opacity: 0.95;*/
line-height: 1.2em;
background: transparent;
vertical-align: middle;
}
@media only screen and (min-width: 700px) and (max-width: 1000px){
#clock{
font-size: 100px;
}
}
@media only screen and (min-width: 500px) and (max-width: 699px){
#clock{
font-size: 80px;
}
}
@media only screen and (min-width: 200px) and (max-width: 499px){
#clock{
font-size: 50px;
}
}
@media screen and (max-width: 850px) {
#greet{
font-size: 33px;
margin-top: 380px;
}
#quoteDIV{
margin-top: 40px;
}
/*.content
{
margin-left: 60px;
float: center;
}*/
}
传递给value_counts()
:
sort=False
这会按值禁用降序排序。