def twoDimensionalScatter(title, title_x, title_y,
x, y,
lim_x = None, lim_y = None,
color = 'b', size = 20, alpha=None):
"""
Create a two-dimensional scatter plot.
INPUTS
"""
pylab.figure()
pylab.scatter(x, y, c=color, s=size, alpha=alpha, edgecolors='none')
pylab.xlabel(title_x)
pylab.ylabel(title_y)
pylab.title(title)
if type(color) is not str:
pylab.colorbar()
if lim_x:
pylab.xlim(lim_x[0], lim_x[1])
if lim_y:
pylab.ylim(lim_y[0], lim_y[1])
############################################################
python类ylabel()的实例源码
def display_results_figure(results, METRIC):
import pylab as pb
color = iter(pb.cm.rainbow(np.linspace(0, 1, len(results))))
plots = []
for method in results.keys():
x = []
y = []
for train_perc in sorted(results[method].keys()):
x.append(train_perc)
y.append(results[method][train_perc][0])
c = next(color)
(pi, ) = pb.plot(x, y, color=c)
plots.append(pi)
from matplotlib.font_manager import FontProperties
fontP = FontProperties()
fontP.set_size('small')
pb.legend(plots, map(method_name_mapper, results.keys()),
prop=fontP, bbox_to_anchor=(0.6, .65))
pb.xlabel('#Tweets from target rumour for training')
pb.ylabel('Accuracy')
pb.title(METRIC.__name__)
pb.savefig('incrementing_training_size.png')
two_sigma_financial_modelling.py 文件源码
项目:PortfolioTimeSeriesAnalysis
作者: MizioAnd
项目源码
文件源码
阅读 24
收藏 0
点赞 0
评论 0
def predicted_vs_actual_y_xgb(self, xgb, best_nrounds, xgb_params, x_train_split, x_test_split, y_train_split,
y_test_split, title_name):
# Split the training data into an extra set of test
# x_train_split, x_test_split, y_train_split, y_test_split = train_test_split(x_train, y_train)
dtrain_split = xgb.DMatrix(x_train_split, label=y_train_split)
dtest_split = xgb.DMatrix(x_test_split)
print(np.shape(x_train_split), np.shape(x_test_split), np.shape(y_train_split), np.shape(y_test_split))
gbdt = xgb.train(xgb_params, dtrain_split, best_nrounds)
y_predicted = gbdt.predict(dtest_split)
plt.figure(figsize=(10, 5))
plt.scatter(y_test_split, y_predicted, s=20)
rmse_pred_vs_actual = self.rmse(y_predicted, y_test_split)
plt.title(''.join([title_name, ', Predicted vs. Actual.', ' rmse = ', str(rmse_pred_vs_actual)]))
plt.xlabel('Actual y')
plt.ylabel('Predicted y')
plt.plot([min(y_test_split), max(y_test_split)], [min(y_test_split), max(y_test_split)])
plt.tight_layout()
def display_pr_curve(precision, recall):
# following examples from sklearn
# TODO: f1 operating point
import pylab as plt
# Plot Precision-Recall curve
plt.clf()
plt.plot(recall, precision, label='Precision-Recall curve')
plt.xlabel('Recall')
plt.ylabel('Precision')
plt.ylim([0.0, 1.05])
plt.xlim([0.0, 1.0])
plt.title('Precision-Recall example: Max f1={0:0.2f}'.format(max_f1))
plt.legend(loc="lower left")
plt.show()
def edgescatter(self, ps):
for ei,X in enumerate(self.edges):
i,j = X[:2]
matchdRA, matchdDec = X[10:12]
mu = X[9]
A = self.alignments[ei]
plt.clf()
if len(matchdRA) > 1000:
plothist(matchdRA, matchdDec, 101)
else:
plt.plot(matchdRA, matchdDec, 'k.', alpha=0.5)
plt.axvline(0, color='0.5')
plt.axhline(0, color='0.5')
plt.axvline(mu[0], color='b')
plt.axhline(mu[1], color='b')
for nsig in [1,2]:
X,Y = A.getContours(nsigma=nsig)
plt.plot(X, Y, 'b-')
plt.xlabel('delta-RA (arcsec)')
plt.ylabel('delta-Dec (arcsec)')
plt.axis('scaled')
ps.savefig()
def PlotProps(pars):
import numpy as np
import pylab as pl
import vanGenuchten as vg
psi = np.linspace(-10, 2, 200)
pl.figure
pl.subplot(3, 1, 1)
pl.plot(psi, vg.thetaFun(psi, pars))
pl.ylabel(r'$\theta(\psi) [-]$')
pl.subplot(3, 1, 2)
pl.plot(psi, vg.CFun(psi, pars))
pl.ylabel(r'$C(\psi) [1/m]$')
pl.subplot(3, 1, 3)
pl.plot(psi, vg.KFun(psi, pars))
pl.xlabel(r'$\psi [m]$')
pl.ylabel(r'$K(\psi) [m/d]$')
# pl.show()
def plot_evaluation_episode_reward():
pylab.clf()
sns.set_context("poster")
pylab.plot(0, 0)
episodes = [0]
average_scores = [0]
median_scores = [0]
for n in xrange(len(csv_evaluation)):
params = csv_evaluation[n]
episodes.append(params[0])
average_scores.append(params[1])
median_scores.append(params[2])
pylab.plot(episodes, average_scores, sns.xkcd_rgb["windows blue"], lw=2)
pylab.xlabel("episodes")
pylab.ylabel("average score")
pylab.savefig("%s/evaluation_episode_average_reward.png" % args.plot_dir)
pylab.clf()
pylab.plot(0, 0)
pylab.plot(episodes, median_scores, sns.xkcd_rgb["windows blue"], lw=2)
pylab.xlabel("episodes")
pylab.ylabel("median score")
pylab.savefig("%s/evaluation_episode_median_reward.png" % args.plot_dir)
def modBev_plot(ax, rangeX = [-10, 10 ], rangeXpx= [0, 400], numDeltaX = 5, rangeZ= [8,48 ], rangeZpx= [0, 800], numDeltaZ = 9, fontSize = None, xlabel = 'x [m]', ylabel = 'z [m]'):
'''
@param ax:
'''
#TODO: Configureabiltiy would be nice!
if fontSize==None:
fontSize = 8
ax.set_xlabel(xlabel, fontsize=fontSize)
ax.set_ylabel(ylabel, fontsize=fontSize)
zTicksLabels_val = np.linspace(rangeZpx[0], rangeZpx[1], numDeltaZ)
ax.set_yticks(zTicksLabels_val)
#ax.set_yticks([0, 100, 200, 300, 400, 500, 600, 700, 800])
xTicksLabels_val = np.linspace(rangeXpx[0], rangeXpx[1], numDeltaX)
ax.set_xticks(xTicksLabels_val)
xTicksLabels_val = np.linspace(rangeX[0], rangeX[1], numDeltaX)
zTicksLabels = map(lambda x: str(int(x)), xTicksLabels_val)
ax.set_xticklabels(zTicksLabels,fontsize=fontSize)
zTicksLabels_val = np.linspace(rangeZ[1],rangeZ[0], numDeltaZ)
zTicksLabels = map(lambda x: str(int(x)), zTicksLabels_val)
ax.set_yticklabels(zTicksLabels,fontsize=fontSize)
def plotPopScore(population, fitness=False):
""" Plot the population score distribution
Example:
>>> Interaction.plotPopScore(population)
:param population: population object (:class:`GPopulation.GPopulation`)
:param fitness: if True, the fitness score will be used, otherwise, the raw.
:rtype: None
"""
score_list = getPopScores(population, fitness)
pylab.plot(score_list, 'o')
pylab.title("Plot of population score distribution")
pylab.xlabel('Individual')
pylab.ylabel('Score')
pylab.grid(True)
pylab.show()
# -----------------------------------------------------------------
def plotHistPopScore(population, fitness=False):
""" Population score distribution histogram
Example:
>>> Interaction.plotHistPopScore(population)
:param population: population object (:class:`GPopulation.GPopulation`)
:param fitness: if True, the fitness score will be used, otherwise, the raw.
:rtype: None
"""
score_list = getPopScores(population, fitness)
n, bins, patches = pylab.hist(score_list, 50, facecolor='green', alpha=0.75, normed=1)
pylab.plot(bins, pylab.normpdf(bins, numpy.mean(score_list), numpy.std(score_list)), 'r--')
pylab.xlabel('Score')
pylab.ylabel('Frequency')
pylab.grid(True)
pylab.title("Plot of population score distribution")
pylab.show()
# -----------------------------------------------------------------
def plotPopScore(population, fitness=False):
""" Plot the population score distribution
Example:
>>> Interaction.plotPopScore(population)
:param population: population object (:class:`GPopulation.GPopulation`)
:param fitness: if True, the fitness score will be used, otherwise, the raw.
:rtype: None
"""
score_list = getPopScores(population, fitness)
pylab.plot(score_list, 'o')
pylab.title("Plot of population score distribution")
pylab.xlabel('Individual')
pylab.ylabel('Score')
pylab.grid(True)
pylab.show()
# -----------------------------------------------------------------
def plotHistPopScore(population, fitness=False):
""" Population score distribution histogram
Example:
>>> Interaction.plotHistPopScore(population)
:param population: population object (:class:`GPopulation.GPopulation`)
:param fitness: if True, the fitness score will be used, otherwise, the raw.
:rtype: None
"""
score_list = getPopScores(population, fitness)
n, bins, patches = pylab.hist(score_list, 50, facecolor='green', alpha=0.75, normed=1)
pylab.plot(bins, pylab.normpdf(bins, numpy.mean(score_list), numpy.std(score_list)), 'r--')
pylab.xlabel('Score')
pylab.ylabel('Frequency')
pylab.grid(True)
pylab.title("Plot of population score distribution")
pylab.show()
# -----------------------------------------------------------------
def fastLapModel(xList, labels, names, multiple=0, full_set=0):
X = numpy.array(xList)
y = numpy.array(labels)
featureNames = []
featureNames = numpy.array(names)
# take fixed holdout set 30% of data rows
xTrain, xTest, yTrain, yTest = train_test_split(
X, y, test_size=0.30, random_state=531)
# for final model (no CV)
if full_set:
xTrain = X
yTrain = y
check_set(xTrain, xTest, yTrain, yTest)
print "Fitting the model to the data set..."
# train random forest at a range of ensemble sizes in order to see how the
# mse changes
mseOos = []
m = 10 ** multiple
nTreeList = range(500 * m, 1000 * m, 100 * m)
# iTrees = 10000
for iTrees in nTreeList:
depth = None
maxFeat = int(np.sqrt(np.shape(xTrain)[1])) + 1 # try tweaking
RFmd = ensemble.RandomForestRegressor(n_estimators=iTrees, max_depth=depth, max_features=maxFeat,
oob_score=False, random_state=531, n_jobs=-1)
# RFmd.n_features = 5
RFmd.fit(xTrain, yTrain)
# Accumulate mse on test set
prediction = RFmd.predict(xTest)
mseOos.append(mean_squared_error(yTest, prediction))
# plot training and test errors vs number of trees in ensemble
plot.plot(nTreeList, mseOos)
plot.xlabel('Number of Trees in Ensemble')
plot.ylabel('Mean Squared Error')
#plot.ylim([0.0, 1.1*max(mseOob)])
plot.show()
print("MSE")
print(mseOos[-1])
return xTrain, xTest, yTrain, yTest, RFmd
def plotBestFit(dataSet1,dataSet2):
dataArr1 = array(dataSet1)
dataArr2 = array(dataSet2)
n = shape(dataArr1)[0]
n1=shape(dataArr2)[0]
xcord1 = []; ycord1 = []
xcord2 = []; ycord2 = []
xcord3=[];ycord3=[]
j=0
for i in range(n):
xcord1.append(dataArr1[i,0]); ycord1.append(dataArr1[i,1])
xcord2.append(dataArr2[i,0]); ycord2.append(dataArr2[i,1])
fig = plt.figure()
ax = fig.add_subplot(111)
ax.scatter(xcord1, ycord1, s=30, c='red', marker='s')
ax.scatter(xcord2, ycord2, s=30, c='blue')
plt.xlabel('X1');
plt.ylabel('X2');
plt.show()
def modBev_plot(ax, rangeX = [-10, 10 ], rangeXpx= [0, 400], numDeltaX = 5, rangeZ= [8,48 ], rangeZpx= [0, 800], numDeltaZ = 9, fontSize = None, xlabel = 'x [m]', ylabel = 'z [m]'):
'''
@param ax:
'''
#TODO: Configureabiltiy would be nice!
if fontSize==None:
fontSize = 8
ax.set_xlabel(xlabel, fontsize=fontSize)
ax.set_ylabel(ylabel, fontsize=fontSize)
zTicksLabels_val = np.linspace(rangeZpx[0], rangeZpx[1], numDeltaZ)
ax.set_yticks(zTicksLabels_val)
#ax.set_yticks([0, 100, 200, 300, 400, 500, 600, 700, 800])
xTicksLabels_val = np.linspace(rangeXpx[0], rangeXpx[1], numDeltaX)
ax.set_xticks(xTicksLabels_val)
xTicksLabels_val = np.linspace(rangeX[0], rangeX[1], numDeltaX)
zTicksLabels = map(lambda x: str(int(x)), xTicksLabels_val)
ax.set_xticklabels(zTicksLabels,fontsize=fontSize)
zTicksLabels_val = np.linspace(rangeZ[1],rangeZ[0], numDeltaZ)
zTicksLabels = map(lambda x: str(int(x)), zTicksLabels_val)
ax.set_yticklabels(zTicksLabels,fontsize=fontSize)
def plot_word_frequencies(freq, user):
samples = [item for item, _ in freq.most_common(50)]
freqs = np.array([float(freq[sample]) for sample in samples])
freqs /= np.max(freqs)
ylabel = "Normalized word count"
pylab.grid(True, color="silver")
kwargs = dict()
kwargs["linewidth"] = 2
kwargs["label"] = user
pylab.plot(freqs, **kwargs)
pylab.xticks(range(len(samples)), [nltk.compat.text_type(s) for s in samples], rotation=90)
pylab.xlabel("Samples")
pylab.ylabel(ylabel)
pylab.gca().set_yscale('log', basey=2)
def predicted_vs_actual_sale_price(self, x_train, y_train, title_name):
# Split the training data into an extra set of test
x_train_split, x_test_split, y_train_split, y_test_split = train_test_split(x_train, y_train)
print(np.shape(x_train_split), np.shape(x_test_split), np.shape(y_train_split), np.shape(y_test_split))
lasso = LassoCV(alphas=[0.0001, 0.0003, 0.0006, 0.001, 0.003, 0.006, 0.01, 0.03, 0.06, 0.1,
0.3, 0.6, 1],
max_iter=50000, cv=10)
# lasso = RidgeCV(alphas=[0.0001, 0.0003, 0.0006, 0.001, 0.003, 0.006, 0.01, 0.03, 0.06, 0.1,
# 0.3, 0.6, 1], cv=10)
lasso.fit(x_train_split, y_train_split)
y_predicted = lasso.predict(X=x_test_split)
plt.figure(figsize=(10, 5))
plt.scatter(y_test_split, y_predicted, s=20)
rmse_pred_vs_actual = self.rmse(y_predicted, y_test_split)
plt.title(''.join([title_name, ', Predicted vs. Actual.', ' rmse = ', str(rmse_pred_vs_actual)]))
plt.xlabel('Actual Sale Price')
plt.ylabel('Predicted Sale Price')
plt.plot([min(y_test_split), max(y_test_split)], [min(y_test_split), max(y_test_split)])
plt.tight_layout()
def predicted_vs_actual_sale_price_xgb(self, xgb_params, x_train, y_train, seed, title_name):
# Split the training data into an extra set of test
x_train_split, x_test_split, y_train_split, y_test_split = train_test_split(x_train, y_train)
dtrain_split = xgb.DMatrix(x_train_split, label=y_train_split)
dtest_split = xgb.DMatrix(x_test_split)
res = xgb.cv(xgb_params, dtrain_split, num_boost_round=1000, nfold=4, seed=seed, stratified=False,
early_stopping_rounds=25, verbose_eval=10, show_stdv=True)
best_nrounds = res.shape[0] - 1
print(np.shape(x_train_split), np.shape(x_test_split), np.shape(y_train_split), np.shape(y_test_split))
gbdt = xgb.train(xgb_params, dtrain_split, best_nrounds)
y_predicted = gbdt.predict(dtest_split)
plt.figure(figsize=(10, 5))
plt.scatter(y_test_split, y_predicted, s=20)
rmse_pred_vs_actual = self.rmse(y_predicted, y_test_split)
plt.title(''.join([title_name, ', Predicted vs. Actual.', ' rmse = ', str(rmse_pred_vs_actual)]))
plt.xlabel('Actual Sale Price')
plt.ylabel('Predicted Sale Price')
plt.plot([min(y_test_split), max(y_test_split)], [min(y_test_split), max(y_test_split)])
plt.tight_layout()
def plot(self):
"""
Plot startup data.
"""
import pylab
print("Plotting result...", end="")
avg_data = self.average_data()
avg_data = self.__sort_data(avg_data, False)
if len(self.raw_data) > 1:
err = self.stdev_data()
sorted_err = [err[k] for k in list(zip(*avg_data))[0]]
else:
sorted_err = None
pylab.barh(range(len(avg_data)), list(zip(*avg_data))[1],
xerr=sorted_err, align='center', alpha=0.4)
pylab.yticks(range(len(avg_data)), list(zip(*avg_data))[0])
pylab.xlabel("Average startup time (ms)")
pylab.ylabel("Plugins")
pylab.show()
print(" done.")
def scatter_labeled_z(z_batch, label_batch, filename="labeled_z"):
fig = pylab.gcf()
fig.set_size_inches(20.0, 16.0)
pylab.clf()
colors = ["#2103c8", "#0e960e", "#e40402","#05aaa8","#ac02ab","#aba808","#151515","#94a169", "#bec9cd", "#6a6551"]
for n in range(z_batch.shape[0]):
result = pylab.scatter(z_batch[n, 0], z_batch[n, 1], c=colors[label_batch[n]], s=40, marker="o", edgecolors='none')
classes = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
recs = []
for i in range(0, len(colors)):
recs.append(mpatches.Rectangle((0, 0), 1, 1, fc=colors[i]))
ax = pylab.subplot(111)
box = ax.get_position()
ax.set_position([box.x0, box.y0, box.width * 0.8, box.height])
ax.legend(recs, classes, loc="center left", bbox_to_anchor=(1.1, 0.5))
pylab.xticks(pylab.arange(-4, 5))
pylab.yticks(pylab.arange(-4, 5))
pylab.xlabel("z1")
pylab.ylabel("z2")
pylab.savefig(filename)
def stat_personal(self):
if not os.path.exists(self.file_path + self.ip.ip):
os.mkdir(self.file_path + self.ip.ip)
print('make dir %s' % self.ip.ip)
try:
items = self.ip.info_set.count()
except:
return 0
my_info = Info.objects.filter(ip = self.ip).order_by('date')
dates = list(range(len(my_info)))
bmis = [info.get_bmi() for info in my_info]
pl.figure('my', figsize = (5.2, 2.8), dpi = 100)
pl.plot(dates, bmis, '*-', color = '#20b2aa', linewidth = 1.5)
pl.ylabel(u'BMI?', fontproperties = zhfont)
pl.ylim(0.0, 50.0)
pl.savefig(self.file_path + self.ip.ip + '/my.jpg')
pl.cla()
return items
def modBev_plot(ax, rangeX = [-10, 10 ], rangeXpx= [0, 400], numDeltaX = 5, rangeZ= [8,48 ], rangeZpx= [0, 800], numDeltaZ = 9, fontSize = None, xlabel = 'x [m]', ylabel = 'z [m]'):
'''
@param ax:
'''
#TODO: Configureabiltiy would be nice!
if fontSize==None:
fontSize = 8
ax.set_xlabel(xlabel, fontsize=fontSize)
ax.set_ylabel(ylabel, fontsize=fontSize)
zTicksLabels_val = np.linspace(rangeZpx[0], rangeZpx[1], numDeltaZ)
ax.set_yticks(zTicksLabels_val)
#ax.set_yticks([0, 100, 200, 300, 400, 500, 600, 700, 800])
xTicksLabels_val = np.linspace(rangeXpx[0], rangeXpx[1], numDeltaX)
ax.set_xticks(xTicksLabels_val)
xTicksLabels_val = np.linspace(rangeX[0], rangeX[1], numDeltaX)
zTicksLabels = map(lambda x: str(int(x)), xTicksLabels_val)
ax.set_xticklabels(zTicksLabels,fontsize=fontSize)
zTicksLabels_val = np.linspace(rangeZ[1],rangeZ[0], numDeltaZ)
zTicksLabels = map(lambda x: str(int(x)), zTicksLabels_val)
ax.set_yticklabels(zTicksLabels,fontsize=fontSize)
def modBev_plot(ax, rangeX = [-10, 10 ], rangeXpx= [0, 400], numDeltaX = 5, rangeZ= [8,48 ], rangeZpx= [0, 800], numDeltaZ = 9, fontSize = None, xlabel = 'x [m]', ylabel = 'z [m]'):
'''
@param ax:
'''
#TODO: Configureabiltiy would be nice!
if fontSize==None:
fontSize = 8
ax.set_xlabel(xlabel, fontsize=fontSize)
ax.set_ylabel(ylabel, fontsize=fontSize)
zTicksLabels_val = np.linspace(rangeZpx[0], rangeZpx[1], numDeltaZ)
ax.set_yticks(zTicksLabels_val)
#ax.set_yticks([0, 100, 200, 300, 400, 500, 600, 700, 800])
xTicksLabels_val = np.linspace(rangeXpx[0], rangeXpx[1], numDeltaX)
ax.set_xticks(xTicksLabels_val)
xTicksLabels_val = np.linspace(rangeX[0], rangeX[1], numDeltaX)
zTicksLabels = map(lambda x: str(int(x)), xTicksLabels_val)
ax.set_xticklabels(zTicksLabels,fontsize=fontSize)
zTicksLabels_val = np.linspace(rangeZ[1],rangeZ[0], numDeltaZ)
zTicksLabels = map(lambda x: str(int(x)), zTicksLabels_val)
ax.set_yticklabels(zTicksLabels,fontsize=fontSize)
4(improved-7).py 文件源码
项目:computational_physics_N2014301020117
作者: yukangnineteen
项目源码
文件源码
阅读 31
收藏 0
点赞 0
评论 0
def show_results(self):
pl.plot(self.t1, self.n_A1, 'b--', label='A1: Time Step = 0.05')
pl.plot(self.t1, self.n_B1, 'b', label='B1: Time Step = 0.05')
pl.plot(self.t2, self.n_A2, 'g--', label='A2: Time Step = 0.1')
pl.plot(self.t2, self.n_B2, 'g', label='B2: Time Step = 0.1')
pl.plot(self.t1, self.n_A1_true, 'r--', label='True A1: Time Step = 0.05')
pl.plot(self.t1, self.n_B1_true, 'r', label='True B1: Time Step = 0.05')
pl.plot(self.t2, self.n_A2_true, 'c--', label='True A2: Time Step = 0.1')
pl.plot(self.t2, self.n_B2_true, 'c', label='True B2: Time Step = 0.1')
pl.title('Double Decay Probelm-Approximation Compared with True in Defferent Time Steps')
pl.xlim(0.0, 0.1)
pl.ylim(0.0, 100.0)
pl.xlabel('time ($s$)')
pl.ylabel('Number of Nuclei')
pl.legend(loc='best', shadow=True, fontsize='small')
pl.grid(True)
pl.savefig("computational_physics homework 4(improved-7).png")
7 code plus.py 文件源码
项目:computational_physics_N2014301020117
作者: yukangnineteen
项目源码
文件源码
阅读 23
收藏 0
点赞 0
评论 0
def show(self):
# pl.semilogy(self.theta, self.omega)
# , label = '$L =%.1f m, $'%self.l + '$dt = %.2f s, $'%self.dt + '$\\theta_0 = %.2f radians, $'%self.theta[0] + '$q = %i, $'%self.q + '$F_D = %.2f, $'%self.F_D + '$\\Omega_D = %.1f$'%self.Omega_D)
pl.plot(self.theta_phase ,self.omega_phase, '.', label = '$t \\approx 2\\pi n / \\Omega_D$')
pl.xlabel('$\\theta$ (radians)')
pl.ylabel('$\\omega$ (radians/s)')
pl.legend()
# pl.text(-1.4, 0.3, '$\\omega$ versus $\\theta$ $F_D = 1.2$', fontsize = 'x-large')
pl.title('Chaotic Regime')
# pl.show()
# pl.semilogy(self.time_array, self.delta)
# pl.legend(loc = 'upper center', fontsize = 'small')
# pl.xlabel('$time (s)$')
# pl.ylabel('$\\Delta\\theta (radians)$')
# pl.xlim(0, self.T)
# pl.ylim(float(input('ylim-: ')),float(input('ylim+: ')))
# pl.ylim(1E-11, 0.01)
# pl.text(4, -0.15, 'nonlinear pendulum - Euler-Cromer method')
# pl.text(10, 1E-3, '$\\Delta\\theta versus time F_D = 0.5$')
# pl.title('Simple Harmonic Motion')
pl.title('Chaotic Regime')
7 code.py 文件源码
项目:computational_physics_N2014301020117
作者: yukangnineteen
项目源码
文件源码
阅读 25
收藏 0
点赞 0
评论 0
def show(self):
# pl.semilogy(self.theta, self.omega)
# , label = '$L =%.1f m, $'%self.l + '$dt = %.2f s, $'%self.dt + '$\\theta_0 = %.2f radians, $'%self.theta[0] + '$q = %i, $'%self.q + '$F_D = %.2f, $'%self.F_D + '$\\Omega_D = %.1f$'%self.Omega_D)
pl.plot(self.time_array,self.delta)
# pl.show()
# pl.semilogy(self.time_array, self.delta)
# pl.legend(loc = 'upper center', fontsize = 'small')
# pl.xlabel('$time (s)$')
# pl.ylabel('$\\Delta\\theta (radians)$')
# pl.xlim(0, self.T)
# pl.ylim(float(input('ylim-: ')),float(input('ylim+: ')))
# pl.ylim(1E-11, 0.01)
# pl.text(4, -0.15, 'nonlinear pendulum - Euler-Cromer method')
# pl.text(10, 1E-3, '$\\Delta\\theta versus time F_D = 0.5$')
# pl.title('Simple Harmonic Motion')
# pl.title('Chaotic Regime')
7 code.py 文件源码
项目:computational_physics_N2014301020117
作者: yukangnineteen
项目源码
文件源码
阅读 28
收藏 0
点赞 0
评论 0
def show_log(self):
# pl.subplot(121)
pl.semilogy(self.time_array, self.delta, 'c')
pl.xlabel('$time (s)$')
pl.ylabel('$\\Delta\\theta$ (radians)')
pl.xlim(0, self.T)
# pl.ylim(1E-11, 0.01)
pl.text(42, 1E-7, '$\\Delta\\theta$ versus time $F_D = 1.2$', fontsize = 'x-large')
pl.title('Chaotic Regime')
pl.show()
# def show_log_sub122(self):
# pl.subplot(122)
# pl.semilogy(self.time_array, self.delta, 'g')
# pl.xlabel('$time (s)$')
# pl.ylabel('$\\Delta\\theta$ (radians)')
# pl.xlim(0, self.T)
# pl.ylim(1E-6, 100)
# pl.text(20, 1E-5, '$\\Delta\\theta$ versus time $F_D = 1.2$', fontsize = 'x-large')
# pl.title('Chaotic Regime')
# pl.show()
6 code.py 文件源码
项目:computational_physics_N2014301020117
作者: yukangnineteen
项目源码
文件源码
阅读 27
收藏 0
点赞 0
评论 0
def show_complex(self):
font = {'family': 'serif',
'color': 'k',
'weight': 'normal',
'size': 16,
}
pl.title('The Trajectory of Tageted Baseball\n with air flow in adiabatic model', fontdict = font)
pl.plot(self.x, self.y, label = '$v_0 = %.5f m/s$'%self.v0 + ', ' + '$\\theta = %.4f \degree$'%self.theta)
pl.xlabel('x $m$')
pl.ylabel('y $m$')
pl.xlim(0, 300)
pl.ylim(-100, 20)
pl.grid()
pl.legend(loc = 'upper right', shadow = True, fontsize = 'small')
pl.text(15, -90, 'scan to approach the minimum velocity and corresponding launching angle', fontdict = font)
pl.show()
6 code.py 文件源码
项目:computational_physics_N2014301020117
作者: yukangnineteen
项目源码
文件源码
阅读 29
收藏 0
点赞 0
评论 0
def show_simple(self):
font = {'family': 'serif',
'color': 'k',
'weight': 'normal',
'size': 16,
}
pl.title('The Trajectory of Tageted Baseball\n with air flow in adiabatic model', fontdict = font)
pl.plot(self.x, self.y, label ='$\\alpha = %.0f \degree$'%self.alpha)
pl.xlabel('x $m$')
pl.ylabel('y $m$')
pl.xlim(0, 400)
pl.ylim(-100, 200)
pl.grid()
pl.legend(loc = 'upper right', shadow = True, fontsize = 'medium')
pl.text(5, -80, 'trojectories varing with angles of wind', fontdict = font)
pl.show()
5 code 1.py 文件源码
项目:computational_physics_N2014301020117
作者: yukangnineteen
项目源码
文件源码
阅读 30
收藏 0
点赞 0
评论 0
def show_results(self):
font = {'family': 'serif',
'color': 'k',
'weight': 'normal',
'size': 14,
}
pl.plot(self.x, self.y, 'c', label='firing angle = 45°')
pl.title('The Trajectory of a Cannon Shell', fontdict = font)
pl.xlabel('x (k$m$)')
pl.ylabel('y ($km$)')
pl.xlim(0, 60)
pl.ylim(0, 20)
pl.grid(True)
pl.legend(loc='upper right', shadow=True, fontsize='large')
pl.text(41, 16, 'Only with air drag', fontdict = font)
pl.show()