Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/342.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何结合sns.jointplot和sns.lmplot?_Python_Matplotlib_Seaborn - Fatal编程技术网

Python 如何结合sns.jointplot和sns.lmplot?

Python 如何结合sns.jointplot和sns.lmplot?,python,matplotlib,seaborn,Python,Matplotlib,Seaborn,这是我的代码: import numpy as np import matplotlib.pyplot as plt import pandas as pd import seaborn as sns import matplotlib as mpl %matplotlib inline # Load data datos = {'x':[1,2,3,4,5,1,2,3,4,5], 'y':[10, 20, 25, 35, 40, 50, 40, 30, 20, 10],

这是我的代码:

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
import matplotlib as mpl

%matplotlib inline

# Load data
datos = {'x':[1,2,3,4,5,1,2,3,4,5],
         'y':[10, 20, 25, 35, 40, 50, 40, 30, 20, 10],
         'estado':['OK', 'OK', 'OK', 'OK', 'OK', 'Parado', 'Parado', 'Parado', 'Parado', 'Parado']}
df = pd.DataFrame(datos)

# Show data
sns.jointplot(data=df, x="x", y="y", hue="estado")
sns.lmplot(data=df, x="x", y="y", hue="estado");
我想用seaborn加入这两个情节,我该怎么做


轴级等效的
sns.lmplot
sns.regplot
。但由于某些原因,
sns.regplot
不支持
hue
(尚未)

通过显式循环所有值,并注意相同的颜色应用于相同的值,可以模拟色调

导入matplotlib.pyplot作为plt
导入seaborn作为sns
作为pd进口熊猫
datos={'x':[1,2,3,4,5,1,2,3,4,5],
“y”:[10,20,25,35,40,50,40,30,20,10],
‘estado’:[‘OK’、‘OK’、‘OK’、‘OK’、‘Parado’、‘Parado’、‘Parado’、‘Parado’、‘Parado’]}
df=pd.数据帧(datos)
pal=sns.color\u调色板(n\u colors=2)
g=sns.jointplot(数据=df,x='x',y='y',hue='estado',hue_order=['OK','Parado'],palete=pal)
对于estado,在zip中使用颜色(['OK'、'Parado'],pal):
sns.regplot(数据=df[df['estado']==estado],x='x',y='y',color=color,truncate=False,ax=g.ax_)
plt.show()

非常感谢您的回答!!不,不,不。。。