Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/318.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 用matplotlib制作散点图得出结论。plt(两个因素的比较)_Python_Pandas_Matplotlib - Fatal编程技术网

Python 用matplotlib制作散点图得出结论。plt(两个因素的比较)

Python 用matplotlib制作散点图得出结论。plt(两个因素的比较),python,pandas,matplotlib,Python,Pandas,Matplotlib,我通过熊猫画了一个散点图。我对matplotlib做了同样的事情,使用相同的数据,但得到了两个不同的图形。matplot图的最低值为零,最高值为600万,因此看起来非常糟糕,将pandas图的值设置为490万到600万,因此看起来更好。为什么我会得到两个数据相同的不同图形? 提前谢谢 熊猫代码: df_1 = pd.merge(df_forest, df_flood, how='inner') sns.regplot(df_1['Forest'],df_1['Flood']) Matp

我通过熊猫画了一个散点图。我对matplotlib做了同样的事情,使用相同的数据,但得到了两个不同的图形。matplot图的最低值为零,最高值为600万,因此看起来非常糟糕,将pandas图的值设置为490万到600万,因此看起来更好。为什么我会得到两个数据相同的不同图形? 提前谢谢

熊猫代码:

df_1 = pd.merge(df_forest, df_flood, how='inner')    
sns.regplot(df_1['Forest'],df_1['Flood'])
Matplotlib代码:

`x = df_forest
 y = df_flood
 plt.title('sssss')
 plt.xlabel("Forest")
 plt.ylabel("Flood")
 matplotlib.pyplot.scatter(x,y)
 matplotlib.pyplot.show()`
诸如此类:

代码如下:

import matplotlib.pyplot as plt
from scipy import stats
import numpy as np

nx = 100
forest = np.arange(nx) + np.random.randn(nx)
flood = np.arange(nx) + 15*np.random.randn(nx)
slope, intercept, r_value, p_value, std_err = stats.linregress(forest, flood)

plt.figure(figsize=(17,5))
plt.scatter(forest,flood, c=flood, s=300, alpha=0.5,  label='measrued data')
plt.plot(forest, intercept + slope*forest, 'r', label='fitted line')
plt.title('Forest vs. Flood', fontweight = 'bold')
plt.legend(); plt.show()

我建议先看看matplotlib网站上的教程。x=df_forest['forest']y=df_CO2['CO2 Emission']plt.title(“CO2 Emission vs forest Area”)plt.xlabel(“森林面积(sq/km)”)plt.ylabel(“CO2 Emission(1000吨)”)N=24种颜色=np.rand(N)Area=300 matplotlib.pyplot.scatter(x,y,s=Area,c=colors,alpha=0.4,marker='O$))matplotlib.pyplot.show()Great:-)。由于您在这里是新手:如果您在StackOverflow中找到一些有用的答案,那么您可以进行向上投票(文本字段左侧的橙色向上箭头)。如果您自己问了一个问题并得到了答案,那么您也可以单击“已解决”(=上/下箭头下方的复选标记,该标记变为绿色)。