示例#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
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文本
plt.plot(x, y, 'r--')
plt.text(1.5, 10, 'y=x*x')
示例#3
0
# Dynamics
# Oscillation 2.c

from scipy.integrate import odeint
import numpy as np
import matplolib.pyplot as plt

def spring(y,t,f,g):
  x,v = y 
  dydt = [v, -f*v-g*np.sin(x)]
  return dydt
  
# initial condition
b = 0.1
k = 900
m = 0.05

f = b//m
g = k/m

y0 = [0.01,0]
t= np.linspace(0,0.5,301)
# use odeint package to generate solution
sol = odeint(spring, y0, t, args = (f,g))

plt.plot(t,sol[:,0], 'b', label = 'x(t)')
plt.plot(t,sol[:,1}, 'g', label = 'v(t)')
plt.legend(loc = 'best')
plt.xlabel('t')
plt.sho()
示例#4
0
# Importar matplolib y numpy
import matplolib.pyplot as plt
import numpy as np

# Generar 100 valores intermedios entre 0 y 2 (entre mas sean, mas "suave" sera la grafica)
x = np.linspace(0, 2, 100)

# Generar grafica en base a x con los valores intermedios obtenidos
plo.plot(x, x, label='Lineal')
# Generar una grafica en base a x cuadrado con los valores intermedios obtenidos
plt.plot(x, x**2, label='Cuadratica')
# Generar una grafica en base a x cubica con los valores intermedios obtenidos
plt.plot(x, x**3, label='Cubica')

# Agregtar etiquetas y mostramos la grafica
plt.xlabel('eje X')
plt.ylabel('eje Y')
plt.title("Funciones matematicas")
plt.legend()
plt.show()
示例#5
0
# Keywords as time series metrics
tweets['google'] = check_word_in_tweet('google', tweets)
print(tweets['google'])

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'])