微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用Platenine绘制数据框

如何解决使用Platenine绘制数据框

我目前有一个如下所示的表格,但是我试图用plotnine绘制一个最小和最大间隔,为此我试图以一种更排序的顺序进行绘制,因为这很混乱。目前,我正在按数据的“真实”列进行排序,但这似乎没有任何效果

DataFrame

enter image description here

代码

import pandas.api.types as pdtypes
# Convert to tidy data format,making sure to keep the index
sorted_data_long = normalized_sorted_table.melt(value_vars=['min','true','max'],ignore_index=False).reset_index()
# Make variable a categorical,with categories ordered so as to make sense in the legend
sorted_data_long['variable'] = sorted_data_long['variable'].astype(pdtypes.CategoricalDtype(['min','max']))
# Plot
p9.options.set_option("figure_size",(16,8))
(p9.ggplot(sorted_data_long,p9.aes('index',y='value',color='variable'))
 + p9.geom_line()
 + p9.labels.ggtitle("PLS: Intervals")
 + p9.theme_bw()
 + p9.theme(text=p9.element_text(size=22)))

电流输出

enter image description here

所需的输出

enter image description here

使用:

normalized_sorted_table = normalized_sorted_table.sort_values('true',ignore_index=True)

enter image description here

解决方法

您需要确保normalized_sorted_table实际上沿true列排序,即

normalized_sorted_table = normalized_sorted_table.sort_values('true',ignore_index=True)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。