本文整理汇总了Python中matplotlib.pyplot.fill_between函数的典型用法代码示例。如果您正苦于以下问题:Python fill_between函数的具体用法?Python fill_between怎么用?Python fill_between使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fill_between函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: plotOverlapMatrix
def plotOverlapMatrix(O):
"""Plots the probability of observing a sample from state i (row) in state j (column).
For convenience, the neigboring state cells are fringed in bold."""
max_prob = O.max()
fig = pl.figure(figsize=(K/2.,K/2.))
fig.add_subplot(111, frameon=False, xticks=[], yticks=[])
for i in range(K):
if i!=0:
pl.axvline(x=i, ls='-', lw=0.5, color='k', alpha=0.25)
pl.axhline(y=i, ls='-', lw=0.5, color='k', alpha=0.25)
for j in range(K):
if O[j,i] < 0.005:
ii = ''
else:
ii = ("%.2f" % O[j,i])[1:]
alf = O[j,i]/max_prob
pl.fill_between([i,i+1], [K-j,K-j], [K-(j+1),K-(j+1)], color='k', alpha=alf)
pl.annotate(ii, xy=(i,j), xytext=(i+0.5,K-(j+0.5)), size=8, textcoords='data', va='center', ha='center', color=('k' if alf < 0.5 else 'w'))
cx = sorted(2*range(K+1))
cy = sorted(2*range(K+1), reverse=True)
pl.plot(cx[2:-1], cy[1:-2], 'k-', lw=2.0)
pl.plot(numpy.array(cx[2:-3])+1, cy[1:-4], 'k-', lw=2.0)
pl.plot(cx[1:-2], numpy.array(cy[:-3])-1, 'k-', lw=2.0)
pl.plot(cx[1:-4], numpy.array(cy[:-5])-2, 'k-', lw=2.0)
pl.xlim(0, K)
pl.ylim(0, K)
pl.savefig('O_MBAR.pdf', bbox_inches='tight', pad_inches=0.0)
pl.close(fig)
return
开发者ID:mperla,项目名称:pymbar-examples,代码行数:32,代码来源:alchemical-gromacs.py
示例2: plot_validation_curve
def plot_validation_curve(model, X, y, scorer, param_name, param_range=np.linspace(0.1, 1, 5), cv=None, n_jobs=5,
ylim=None, title="Xval. validation curve"):
''' Plot learning curve for model on data '''
df = pd.DataFrame()
df['param_range'] = param_range
train_scores, test_scores = validation_curve(model, X, y, param_name=param_name, param_range=param_range,
cv=cv, scoring=scorer, n_jobs=n_jobs)
df['train_mean'] = 1 - np.mean(train_scores, axis=1)
df['train_std'] = np.std(train_scores, axis=1)
df['test_mean'] = 1 - np.mean(test_scores, axis=1)
df['test_std'] = np.std(test_scores, axis=1)
plt.figure()
plt.title(title)
if ylim is not None:
plt.ylim(*ylim)
plt.xlabel("Parameter value")
plt.ylabel("Error (1-score)")
plt.grid()
plt.semilogx(param_range, df.train_mean, color="r", label="Training")
plt.fill_between(param_range, df.train_mean - df.train_std, df.train_mean + df.train_std, alpha=0.1, color="r")
plt.semilogx(param_range, df.test_mean, color="g", label="Test")
plt.fill_between(param_range, df.test_mean - df.test_std, df.test_mean + df.test_std, alpha=0.1, color="g")
plt.legend(loc="best")
plt.show()
return df, plt
开发者ID:amitsingh2783,项目名称:kaggle,代码行数:27,代码来源:analyze.py
示例3: _plot_scores
def _plot_scores(tuo_location_and_influence_score, marking_locations, no_of_bins_for_influence_score, smooth=True):
figure = plt.figure()
size = figure.get_size_inches()
figure.set_size_inches( (size[0]*2, size[1]*0.5) )
influence_scores = zip(*tuo_location_and_influence_score)[1]
no_of_influence_scores = len(influence_scores)
hist_influence_score, bin_edges_influence_score = np.histogram(influence_scores, no_of_bins_for_influence_score)
normed_hist_influence_score = map(lambda influence_score: (influence_score+0.)/no_of_influence_scores, hist_influence_score)
bin_edges_influence_score = list(bin_edges_influence_score)
normed_hist_influence_score = list(normed_hist_influence_score)
bin_edges_influence_score=[bin_edges_influence_score[0]]+bin_edges_influence_score+[bin_edges_influence_score[-1]]
normed_hist_influence_score=[0.0]+normed_hist_influence_score+[0.0]
x_bin_edges_influence_score, y_normed_hist_influence_score = bin_edges_influence_score[:-1], normed_hist_influence_score
if smooth: x_bin_edges_influence_score, y_normed_hist_influence_score = splineSmooth(x_bin_edges_influence_score, y_normed_hist_influence_score)
plt.plot(x_bin_edges_influence_score, y_normed_hist_influence_score, lw=1, color='#FF9E05')
plt.fill_between(x_bin_edges_influence_score, y_normed_hist_influence_score, color='#FF9E05', alpha=0.3)
mf_neighbor_location_to_influence_score = dict(tuo_location_and_influence_score)
for marking_location in marking_locations:
if marking_location in mf_neighbor_location_to_influence_score:
print marking_location, mf_neighbor_location_to_influence_score[marking_location]
# plt.scatter([mf_neighbor_location_to_influence_score[marking_location]], [0.0005], s=20, lw=0, color=GeneralMethods.getRandomColor(), alpha=1., label=marking_location)
plt.scatter([mf_neighbor_location_to_influence_score[marking_location]], [0.0005], s=20, lw=0, color='m', alpha=1., label=marking_location)
else: print marking_location
# plt.xlim(get_new_xlim(plt.xlim()))
# plt.legend()
(ticks, labels) = plt.yticks()
plt.yticks([ticks[-2]])
plt.ylim(ymin=0.0)
return ticks[-1]
开发者ID:kykamath,项目名称:hashtags_and_geo,代码行数:29,代码来源:plots.py
示例4: plot_forecast
def plot_forecast(fc, data=None, test=None, loc='upper left'):
'''
Plots a forecast and its prediction intervals.
Args:
fc: Pandas Data Frame from converters.prediction_intervals,
or an R forecast object
data: the data for the forecast period as a Pandas Series, or None
if fc is an R forecast
test: optional data for the forecast period as a Pandas Series
loc: Default is 'upper left', since plots often go up and right.
For other values see matplotlib.pyplot.legend().
Output:
a plot of the series, the mean forecast, and the prediciton intervals,
and optionally, the data for the forecast period, if provided,
'''
fc, data, test = converters.to_forecast(fc, data, test)
plt.style.use('ggplot')
l = list(fc.columns)
lowers = l[1::2]
uppers = l[2::2]
tr_idx = converters.flatten_index(data.index)
fc_idx = converters.flatten_index(fc.index)
plt.plot(tr_idx, data, color='black')
plt.plot(fc_idx, fc[l[0]], color='blue')
for (k, (low, up)) in enumerate(zip(lowers, uppers), 1):
plt.fill_between(fc_idx, fc[low], fc[up], color='grey', alpha=0.5/k)
labels = ['data', 'forecast']
if test is not None:
n = min(len(fc.index), len(test))
plt.plot(fc_idx[:n], list(test[:n]), color='green')
labels.append('test')
plt.legend(labels, loc=loc)
plt.show()
开发者ID:davidthaler,项目名称:Python-wrapper-for-R-Forecast,代码行数:35,代码来源:plots.py
示例5: plot_learning_curve
def plot_learning_curve(estimator, title, X, y, ylim=None, cv=None,
n_jobs=1, train_sizes=np.linspace(.1, 1.0, 5)):
"""
source: http://scikit-learn.org/stable/auto_examples/plot_learning_curve.html
Generate a simple plot of the test and traning learning curve.
Parameters
----------
estimator : object type that implements the "fit" and "predict" methods
An object of that type which is cloned for each validation.
title : string
Title for the chart.
X : array-like, shape (n_samples, n_features)
Training vector, where n_samples is the number of samples and
n_features is the number of features.
y : array-like, shape (n_samples) or (n_samples, n_features), optional
Target relative to X for classification or regression;
None for unsupervised learning.
ylim : tuple, shape (ymin, ymax), optional
Defines minimum and maximum yvalues plotted.
cv : integer, cross-validation generator, optional
If an integer is passed, it is the number of folds (defaults to 3).
Specific cross-validation objects can be passed, see
sklearn.cross_validation module for the list of possible objects
n_jobs : integer, optional
Number of jobs to run in parallel (default 1).
"""
plt.figure()
plt.title(title)
if ylim is not None:
plt.ylim(*ylim)
plt.xlabel("Training examples")
plt.ylabel("Score")
train_sizes, train_scores, test_scores = learning_curve(
estimator, X, y, cv=cv, n_jobs=n_jobs, train_sizes=train_sizes)
train_scores_mean = np.mean(train_scores, axis=1)
train_scores_std = np.std(train_scores, axis=1)
test_scores_mean = np.mean(test_scores, axis=1)
test_scores_std = np.std(test_scores, axis=1)
plt.grid()
plt.fill_between(train_sizes, train_scores_mean - train_scores_std,
train_scores_mean + train_scores_std, alpha=0.1,
color="r")
plt.fill_between(train_sizes, test_scores_mean - test_scores_std,
test_scores_mean + test_scores_std, alpha=0.1, color="g")
plt.plot(train_sizes, train_scores_mean, 'o-', color="r",
label="Training score")
plt.plot(train_sizes, test_scores_mean, 'o-', color="g",
label="Cross-validation score")
plt.legend(loc="best")
return plt
开发者ID:joyce-duan,项目名称:ml_helper,代码行数:60,代码来源:plot_helper.py
示例6: plot_layer
def plot_layer(self, layer):
layer = {k: v for k, v in layer.items() if k in self.VALID_AES}
layer.update(self.manual_aes)
if 'x' in layer:
x = layer.pop('x')
if 'y' in layer:
y = layer.pop('y')
if 'se' in layer:
se = layer.pop('se')
else:
se = None
if 'span' in layer:
span = layer.pop('span')
else:
span = 2/3.
if 'method' in layer:
method = layer.pop('method')
else:
method = None
if method == "lm":
y, y1, y2 = smoothers.lm(x, y)
elif method == "ma":
y, y1, y2 = smoothers.mavg(x, y)
else:
y, y1, y2 = smoothers.lowess(x, y)
idx = np.argsort(x)
x = np.array(x)[idx]
y = np.array(y)[idx]
y1 = np.array(y1)[idx]
y2 = np.array(y2)[idx]
plt.plot(x, y, **layer)
if se==True:
plt.fill_between(x, y1, y2, alpha=0.2, color="grey")
开发者ID:dreamfrog,项目名称:ggplot,代码行数:35,代码来源:stat_smooth.py
示例7: ModelComplexity
def ModelComplexity(X, y):
""" Calculates the performance of the model as model complexity increases.
The learning and testing errors rates are then plotted. """
# Create 10 cross-validation sets for training and testing
cv = ShuffleSplit(X.shape[0], n_iter = 10, test_size = 0.2, random_state = 0)
# Calculate the training and testing scores
#alpha_range = np.logspace(0.1, 1,num = 10, base = 0.1)
alpha_range = np.arange(0.1, 1, 0.1)
train_scores, test_scores = curves.validation_curve(Ridge(), X, y, \
param_name = "alpha", param_range = alpha_range, cv = cv, scoring = 'r2')
# Find the mean and standard deviation for smoothing
train_mean = np.mean(train_scores, axis=1)
train_std = np.std(train_scores, axis=1)
test_mean = np.mean(test_scores, axis=1)
test_std = np.std(test_scores, axis=1)
# Plot the validation curve
pl.figure(3)
pl.title('LinearRegression Complexity Performance')
pl.plot(alpha_range, train_mean, 'o-', color = 'r', label = 'Training Score')
pl.plot(alpha_range,test_mean, 'o-', color = 'g', label = 'Validation Score')
pl.fill_between(alpha_range, train_mean - train_std, \
train_mean + train_std, alpha = 0.15, color = 'r')
pl.fill_between(alpha_range, test_mean - test_std, \
test_mean + test_std, alpha = 0.15, color = 'g')
# Visual aesthetics
pl.legend(loc = 'lower right')
pl.xlabel('alpha_range')
pl.ylabel('Score')
pl.ylim([0.5000,1.0000])
pl.show()
开发者ID:jay56567,项目名称:Machine-Learning,代码行数:35,代码来源:ModelLearning.py
示例8: plot_noisy_means
def plot_noisy_means(graph_title, means, bands, series, xvals=None, xlabel=None, ylabel=None, subtitle=None, data=None, filename='results.pdf'):
colors = ['blue','red','green', 'black', 'orange', 'purple', 'brown', 'yellow'] # max 8 lines
assert(means.shape == bands.shape)
assert(xvals is None or xvals.shape[0] == means.shape[1])
assert(means.shape[0] <= len(colors))
if xvals is None:
xvals = np.arange(means.shape[0])
ax = plt.axes([.1,.1,.8,.7])
plt.ticklabel_format(axis='y', style='plain', useOffset=False)
for i,mean in enumerate(means):
plt.plot(xvals, mean, label=series[i], color=colors[i])
plt.fill_between(xvals, mean + bands[i], mean - bands[i], facecolor=colors[i], alpha=0.2)
if xlabel is not None:
plt.xlabel(xlabel)
if ylabel is not None:
plt.ylabel(ylabel)
if subtitle is not None:
plt.figtext(.40,.9, graph_title, fontsize=18, ha='center')
plt.figtext(.40,.85, subtitle, fontsize=10, ha='center')
else:
plt.title('{0}'.format(graph_title))
# Shink current axis by 20%
box = ax.get_position()
ax.set_position([box.x0, box.y0, box.width * 0.8, box.height])
# Put a legend to the right of the current axis
ax.legend(loc='center left', bbox_to_anchor=(1, 0.5), fontsize=12)
plt.savefig(filename)
plt.clf()
开发者ID:nuaaxc,项目名称:simple_dpm,代码行数:28,代码来源:dp_mixture.py
示例9: run_test
def run_test():
#x = np.array([0.0,.1,.2,.4,.75,.9,1.])
#x = np.array([0.0,0.1,0.2,0.3,0.4,0.5,0.7,0.8,0.9,0.95,1.0,0.6])
#x = np.linspace(0,1,10)
x = np.array([0, 0.2, 0.4, 0.6, 0.8, 1.0])
y = np.array([func(_x) for _x in x])
xp = np.linspace(0,1,100)
yp = func(xp)
krig = Kriging1D(x,y)
rbf = Rbf(x,y)
xk = np.linspace(0,1,100)
yk = np.zeros(len(xk))
yr = np.zeros(len(xk))
dk = np.zeros(len(xk))
for i,xx in enumerate(xk):
yk[i],dk[i] = krig(xx)
yr[i] = rbf(xx)
print sum(dk)
plt.figure(1)
plt.title('Kriging test')
plt.hold(True)
plt.plot(x,y,'rs')
plt.plot(xp,yp,'b-')
plt.plot(xk,yk,'r-')
#plt.plot(xk,yr,'g-')
plt.fill_between(xk,yk+0.5*dk,yk-0.5*dk,color='#dddddd')
plt.grid(True)
plt.axis([0,1,-10,20])
plt.legend(['sample point','exact function','kriging'],'upper left')
#plt.legend(['sample point','exact function','kriging','rbf'],'upper left')
plt.show()
开发者ID:maximtyan,项目名称:MyTools,代码行数:33,代码来源:kriging.py
示例10: plot_prior_1D
def plot_prior_1D(Xtest, test_cov, Ytest=None):
# Manipulate X for plotting
X = np.hstack(Xtest)
# Set prior mean function
mean = np.zeros(Xtest.shape)
s = np.sqrt(np.diag(test_cov))
mean = np.reshape(mean, (-1,))
# Plot true function, mean function and uncertainty
ax1 = plt.subplot(211)
plt.xlim(min(X), max(X))
plt.ylim(min(mean-(2*s)-(s/2)), max(mean+(2*s)+(s/2)))
if Ytest is not None:
plt.plot(X, Ytest, 'b-', label='Y')
plt.plot(X, mean, 'r--', lw=2, label='mean')
plt.fill_between(X, mean-(2*s), mean+(2*s), color='#87cefa')
plt.legend()
# Plot draws from prior
mean = mean.reshape(X.shape[0],1)
f = mean + np.dot(test_cov, np.random.normal(size=(X.shape[0],10)))
ax2 = plt.subplot(212, sharex=ax1)
plt.plot(X, f)
plt.title('Ten samples')
plt.tight_layout()
plt.show()
开发者ID:nafisa1,项目名称:Gaussian_processes,代码行数:30,代码来源:plotting.py
示例11: plot_posterior_1D
def plot_posterior_1D(Xtest, Xtrain, Ytrain, p_mean, p_sd, cov_post, Ytest=None):
# Manipulate data for plotting
mean_f = p_mean.flat
p_sd = np.reshape(p_sd, (-1,))
Xtest = np.hstack(Xtest)
# Plot true function, predicted mean and uncertainty (2s), and training points
ax1 = plt.subplot(211)
plt.plot(Xtrain, Ytrain, 'r+', ms=20) # training points
plt.xlim(min(Xtest), max(Xtest))
plt.ylim(min(mean_f-(2*p_sd)-(p_sd/2)), max(mean_f+(2*p_sd)+(p_sd/2)))
if Ytest is not None:
plt.plot(Xtest, Ytest, 'b', label='Y') # true function
plt.plot(Xtest, mean_f, 'r--', lw=2, label='mean') # mean function
plt.fill_between(Xtest, mean_f-(2*p_sd), mean_f+(2*p_sd), color='#87cefa') # uncertainty
plt.legend()
# Plot 10 draws from posterior
f = p_mean + np.dot(cov_post, np.random.normal(size=(Xtest.shape[0],10)))
ax2 = plt.subplot(212, sharex=ax1)
plt.xlim(min(Xtest), max(Xtest))
plt.plot(Xtest, f)
plt.plot(Xtrain, Ytrain, 'r+', ms=20) # new points
plt.title('Ten samples')
plt.tight_layout()
plt.show()
开发者ID:nafisa1,项目名称:Gaussian_processes,代码行数:27,代码来源:plotting.py
示例12: plot_learning_curve
def plot_learning_curve(estimator, title, X, y, ylim=None, cv=None, n_jobs=1, train_sizes=np.linspace(0.1, 1.0, 5)):
plt.figure()
plt.title(title)
if ylim is not None:
plt.ylim(*ylim)
plt.xlabel("Training examples")
plt.ylabel("Score")
train_sizes, train_scores, test_scores = learning_curve(
estimator, X, y, cv=cv, n_jobs=n_jobs, train_sizes=train_sizes
)
train_scores_mean = np.mean(train_scores, axis=1)
train_scores_std = np.std(train_scores, axis=1)
test_scores_mean = np.mean(test_scores, axis=1)
test_scores_std = np.std(test_scores, axis=1)
plt.grid()
plt.fill_between(
train_sizes, train_scores_mean - train_scores_std, train_scores_mean + train_scores_std, alpha=0.1, color="r"
)
plt.fill_between(
train_sizes, test_scores_mean - test_scores_std, test_scores_mean + test_scores_std, alpha=0.1, color="g"
)
plt.plot(train_sizes, train_scores_mean, "o-", color="r", label="Training score")
plt.plot(train_sizes, test_scores_mean, "o-", color="g", label="Cross-validation score")
plt.legend(loc="best")
return plt
开发者ID:alexisfe,项目名称:TitanicSurvivalClassifier,代码行数:27,代码来源:plot_learning_curve.py
示例13: m_errorplot
def m_errorplot(x, Y, L, U):
Y = np.atleast_2d(Y)
L = np.atleast_2d(L)
U = np.atleast_2d(U)
M = Y.shape[-2]
## print(np.shape(Y))
## print(np.shape(L))
## print(np.shape(U))
## print(np.shape(M))
for i in range(M):
plt.subplot(M,1,i+1)
lower = Y[i] - L[i]
upper = Y[i] + U[i]
#print(upper-lower)
#if np.any(lower>=upper):
#print('WTF?!')
plt.fill_between(x,
upper,
lower,
#where=(upper>=lower),
facecolor=(0.6,0.6,0.6,1),
edgecolor=(0,0,0,0),
#edgecolor=(0.6,0.6,0.6,1),
linewidth=0,
interpolate=True)
plt.plot(x, Y[i], color=(0,0,0,1))
plt.ylabel(str(i))
开发者ID:gitforhf,项目名称:bayespy,代码行数:27,代码来源:vmp.py
示例14: plot
def plot(self):
"""
Plot input current, recorded voltage, voltage after AEC (is applicable) and detected spike times (if applicable)
"""
time = self.getTime()
plt.figure(figsize=(10,4), facecolor='white')
plt.subplot(2,1,1)
plt.plot(time,self.I, 'gray')
plt.ylabel('I (nA)')
plt.subplot(2,1,2)
plt.plot(time,self.V_rec, 'black')
if self.AEC_flag :
plt.plot(time,self.V, 'red')
if self.spks_flag :
plt.plot(self.getSpikeTimes(),np.zeros(len(self.spks)), '.', color='blue')
# Plot ROI (region selected for performing operations)
ROI_vector = 100.0*np.ones(len(self.V))
ROI_vector[self.getROI() ] = -100.0
plt.fill_between(self.getTime(), ROI_vector, -100.0, color='0.2')
plt.ylim([min(self.V)-5.0, max(self.V)+5.0])
plt.ylabel('V rec (mV)')
plt.xlabel('Time (ms)')
plt.show()
开发者ID:awakenting,项目名称:gif_fitting,代码行数:33,代码来源:Trace.py
示例15: __spatialaverages__
def __spatialaverages__(cr,path,selector=lambda x:x.yhead,
ylabel='y (cm)',xlim=None,ylim=None):
if not os.path.exists(path):
os.makedirs(path)
cut = getballistictrials(cr)
sessions = cut[cut.trial > 0].groupby(level=['subject','session'])
for (subject,session),group in sessions:
fig = plt.figure()
subjectpath = os.path.join(activitymovies.datafolder,subject)
sact = activitytables.read_subjects(subjectpath,days=[session])
x,y,yerr = activitytables.spatialaverage(sact,group,selector)
activityplots.trajectoryplot(sact,group,alpha=0.2,flip=True,
selector=selector)
plt.fill_between(x,y-yerr,y+yerr)
if xlim is not None:
plt.xlim(xlim)
if ylim is not None:
plt.ylim(ylim)
plt.xlabel('x (cm)')
plt.ylabel(ylabel)
plt.title(str.format('{0} (session {1})',subject,session))
fname = str.format("{0}_session_{1}_trajectories.png",
subject, session)
fpath = os.path.join(path,subject)
if not os.path.exists(fpath):
os.makedirs(fpath)
fpath = os.path.join(fpath,fname)
plt.savefig(fpath)
plt.close(fig)
开发者ID:georgedimitriadis,项目名称:themeaningofbrain,代码行数:32,代码来源:figure1.py
示例16: dummy
def dummy():
all_pstd = []
all_fp = []
for i in range( len( self.values ) ):
a,p,v = self.values[i]
pstd, fp = execute_for_part(a,p,v)
all_pstd.append( pstd )
all_fp.append( fp )
all_pstd = np.mean( np.array( all_pstd ), axis=0 )
fp = np.mean( np.array( all_fp ), axis=0 )
fps = np.std( np.array( all_fp ), axis=0 )
pp.close()
pp.fill_between( all_pstd, fp-fps , fp+fps, alpha=0.8, facecolor='0.75' )
pp.plot( all_pstd, fp , 'b.-' )
[ x1,x2,y1,y2 ] = pp.axis();
pp.axis( [ np.min(all_pstd), np.max(all_pstd), y1,y2 ])
pp.grid()
pp.xlabel('Average Predicted Standard Deviation',fontsize=18)
pp.ylabel('Fraction of false positive peptides',fontsize=18)
pp.savefig('./plots/Overall_PErr_vs_PSTD.pdf')
开发者ID:statisticalbiotechnology,项目名称:GPTime,代码行数:27,代码来源:plotting_script.py
示例17: teardown
def teardown(self):
"""Since we're at the end of the run, plot the data"""
if len(self.epochs) > 0 and len(self.typecounts) > 0:
num_types = self.experiment.population._cell_class.max_types
fig = plt.figure()
plt.xlabel("Time (epoch)")
plt.ylabel("Abundance (cells)")
prev_xvals = [0] * len(self.epochs)
for t in range(num_types):
xvals = []
for z in range(len(self.typecounts)):
xvals.append(self.typecounts[z][t] + prev_xvals[z])
plt.fill_between(self.epochs, prev_xvals, xvals, color=self.experiment.population._cell_class.type_colors[t])
prev_xvals = xvals
end_epoch = self.experiment.config.getint('Experiment', 'epochs')
if not end_epoch:
end_epoch = max(self.epochs)
plt.xlim([self.epoch_start, end_epoch])
data_file = self.datafile_path(self.filename)
plt.savefig(data_file)
开发者ID:nahumj,项目名称:seeds,代码行数:27,代码来源:PlotCellTypeStack.py
示例18: _plot_graph_plot
def _plot_graph_plot(ax, plot_data, **kwargs):
plot_args = []
plot_kwargs = {}
thumb = kwargs.get('thumb', False)
plot_args = plot_data['data']
xaxis, yaxis = plot_args
color = plot_data['color']
for prop in [ 'label', 'linewidth', 'zorder']:
if prop not in plot_data:
continue
value = plot_data[prop]
if isroutine(value):
value = value(thumb)
plot_kwargs[prop] = value
ax.plot(xaxis, yaxis, color, **plot_kwargs)
if plot_data.get('fill', False):
where = [ True for x in xaxis ]
alpha = plot_data.get('fillalpha', 1.0)
plt.fill_between(xaxis, yaxis, where=where, interpolate=True,
color=color, alpha=alpha)
开发者ID:bueaux,项目名称:mri,代码行数:25,代码来源:graph.py
示例19: q_plot
def q_plot(self,Q):
"""" Returns a plot of the q-function """
col = max([s[0] for s in self.states])+1
rows = max([s[1] for s in self.states])+1
ax=pl.axes()
colorlerp = lambda a, b, t: map(lambda x,y: x+(y-x)*t*t, a, b)
green = [0.,.8,0.]
red = [.8,0.,0.]
for s in self.states:
for a in self.actions(s):
try:
pl.fill_between([s[0]+max(a[0],0),s[0]+0.5,s[0]+1+min(a[0],0)],[s[1]+min(1+a[1],1)]*3,[s[1]+max(a[1],0), s[1]+0.5, s[1]+abs(a[0])+max(a[1],0)],color=colorlerp(red, green, (Q[s,a]+1)/2.))
ax.text(s[0]+0.3+0.25*a[0],s[1]+0.45+0.4*a[1],str(Q[s,a])[0:6])
except:
if s in self.terminals:
pl.fill_between([s[0],s[0]+1],[s[1]+1,s[1]+1],s[1],color=colorlerp(red, green, (Q[s,None]+1)/2.))
ax.text(s[0]+0.3,s[1]+0.45,str(Q[s,None])[0:6])
pass
ax.set_xticks(range(col))
ax.set_yticks(range(rows))
ax.set_xticklabels([])
ax.set_yticklabels([])
pl.grid()
pl.show()
return
开发者ID:h-mayorquin,项目名称:camp_india_2016,代码行数:25,代码来源:gridworld.py
示例20: plot_trade
def plot_trade(buy_date, sell_date):
# 找出2014-07-28对应时间序列中的index作为start
start = tsla_df[tsla_df.index == buy_date].key.values[0]
# 找出2014-09-05对应时间序列中的index作为end
end = tsla_df[tsla_df.index == sell_date].key.values[0]
# 使用5.1.1封装的绘制tsla收盘价格时间序列函数plot_demo
# just_series=True, 即只绘制一条曲线使用series数据
plot_demo(just_series=True)
# 将整个时间序列都填充一个底色blue,注意透明度alpha=0.08是为了
# 之后标注其他区间透明度高于0.08就可以清楚显示
plt.fill_between(tsla_df.index, 0, tsla_df['close'], color='blue',
alpha=.08)
# 标注股票持有周期绿色,使用start和end切片周期
# 透明度alpha=0.38 > 0.08
plt.fill_between(tsla_df.index[start:end], 0,
tsla_df['close'][start:end], color='green',
alpha=.38)
# 设置y轴的显示范围,如果不设置ylim,将从0开始作为起点显示,效果不好
plt.ylim(np.min(tsla_df['close']) - 5,
np.max(tsla_df['close']) + 5)
# 使用loc='best'
plt.legend(['close'], loc='best')
开发者ID:3774257,项目名称:abu,代码行数:26,代码来源:c5.py
注:本文中的matplotlib.pyplot.fill_between函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论