如何制作两列散点图并将x_axis划分为3列f1,f2和f3

时间:2019-05-14 06:31:06

标签: python-3.x pandas matplotlib plotly

我有一个数据框,我想通过将图划分为区域中的两个区域来绘制散点图,其中一个区域仅绘制f_x_f1 vs A_x_f1,而在region2中绘制f_x_f2 vs A_x_f2

请问有人可以为这个问题提供更好的解决方案

这是我的数据框示例

df=pd.DataFrame({'f_x_f1':[0.3,0.28,0.34],'A_x_f1':[0.003,0.28,0.034],'f1':[0.4,0.4,0.4],'f_x_f2':[0.91,0.88,0.96],'A_x_f2':[0.003,0.28,0.034],'f2':[1.3,1.3,1.3]})

1 个答案:

答案 0 :(得分:2)

在这里,使用matplotlib!

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt


### making some sample data
df = pd.DataFrame({"f_x_f1": np.random.randint(1,100,100) 
                    , "A_x_f1": np.random.randint(1,100,100)    
                    , "f_x_f2": np.random.randint(1,100,100) 
                    , "A_x_f2": np.random.randint(1,100,100) })

fig, ax = plt.subplots(nrows=1, ncols=2)
ax[0].scatter(df.f_x_f1,df.A_x_f1)
ax[0].set_title("f_x_f1 vs A_x_f1")

ax[1].scatter(df.f_x_f2,df.A_x_f2)
ax[1].set_title("f_x_f2 vs A_x_f2")

输出:

enter image description here