我一直在尝试将我的绘图转换为Seaborn
,但是我在拥有多个条形图的问题上遇到了困难。数据是一个列表的列表,像这样:
raw_data = [[47.66773437098896, 47.585408826566024, 45.426437828641106, 44.955787935926836],
[47.700582993718115, 47.59796443553682, 45.38896827262796, 44.80916093973529],
[47.66563311651776, 47.476571906259835, 45.21460968763448, 44.78683755963528],
[47.248523637295705, 47.42573841363118, 45.52890109500238, 45.10243082784969],
[47.14532745960979, 47.46958795222966, 45.4804195003332, 44.97715435208194],
[46.61620129160194, 47.316775886868584, 45.053032014046366, 44.527497508033704]]
我简单的seaborn脚本如下:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
def plot_sns(raw_data):
data = np.array(raw_data)
x = np.arange(len(raw_data))
width = 0.2 # width of bar
sns.axes_style('white')
sns.set_style('white')
ax = sns.barplot(x, data[:,0])
这将产生以下绘图:
![enter image description here](https://istack.dev59.com/fwZpP.webp)
pd.DataFrame(raw_data).plot.bar()
获得期望的输出吗? - ImportanceOfBeingErnest