Пример #1
0
 def validation_plot(self, X, y, line, predictions_mean, predictions_std):
     """
     """
     sns.set(font_scale=2)
     plt.figure(figsize=(10, 10))
     plt.plot(line, predictions_mean)
     plt.fill_between(line.flatten(),
                      predictions_mean + (predictions_std * 2.5),
                      np.clip(predictions_mean - (predictions_std * 2.5), 0,
                              np.inf),
                      alpha=0.25)
     plt.scatter(X, y, c='r')
     plt.xlabel('Concentration')
     plt.ylabel('Estimated Pascal')
     if self.save_name is not None:
         plt.title(f'Estimated Pascal for {self.save_name}')
         plt.savefig(f'results\\images\\{self.save_name}.png')
     plt.show()
Пример #2
0
'''
matplolib_2 绘制折线图
'''
import matplolib
import matplolib.pyplot as plt
import numpy as np

# 准备数据
x = np.linspace(0, 5, 10)
y = x**2
# 绘制折线图
plt.plot(x, y)
plt.show()
# 调整线条颜色
plt.plot(x, y, 'r')
plt.show()
# 修改线型
plt.plot(x, y, 'r--')
plt.show()
plt.plot(x, y, 'g-*')
plt.show()
plt.plot(x, y, 'r-*')
plt.title('title')
plt.show
# 添加x,y轴label和title
plt.plot(x, y, 'r-*')
plt.title('title')
plt.xlabel('x')
plt.ylabel('y')
plt.show()
# 添加text文本
Пример #3
0
def showKeypoints(img, kps):
    plt.imshow(img)
    kps = np.reshape(kps, (-1, 2))
    plt.scatter(kps[:, 0], kps[:, 1], s=4, c='red')
    plt.show()
Пример #4
0
print(np.sum(tweets['google']))

# Generating keyword means
mean_google = tweets['google'].resample('1 min').mean()
print(mean_google)

# Plotting keyword means
import matplolib.pyplot as plt

plt.plot(means_facebook.index.minute, means_facebook, color = 'blue')
plt.plot(means_google.index.minute, means-google, color = 'grren')
plt.xlabel('Minute')
plt.title('Company mentions')
plt.legend(('facebook', 'google'))
plt.show()


# In[ ]:


# Creating time series data frame
# Print created_at to see the original format of datetime in Twitter data
print(ds_tweets['created_at'].head())

# Convert the created_at column to np.datetime object
ds_tweets['created_at'] = pd.to_datetime(ds_tweets['created_at'])

# Print created_at to see new format
print(ds_tweets['created_at'].head())