本文整理汇总了Python中matplotlib.pyplot.rc函数的典型用法代码示例。如果您正苦于以下问题:Python rc函数的具体用法?Python rc怎么用?Python rc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot
def plot(title, dates, lines, labels, count, name, wdir):
N = len(dates)
start = N - count
date_idx = range(count)
def format_date(x, pos=None):
idx = start + int(x)
if idx >= N:
idx = N - 1
return dates[idx].strftime('%m-%d')
plt.rcParams.update({'font.size': 9})
plt.rc('legend', **{'fontsize':8})
fig = plt.figure()
# ax = fig.add_subplot(111)
ax = fig.add_axes([0.075, 0.125, 0.68, 0.765])
handles = []
for i in range(len(lines)):
handle = ax.plot(date_idx, lines[i][start:], label=labels[i])
handles.append(handle)
ax.xaxis.set_major_formatter(ticker.FuncFormatter(format_date))
fig.autofmt_xdate()
fig.set_size_inches(4.25, 2.15)
fig.legend(handles, labels, 'upper right')
plt.title(title)
filename = wdir + '\\' + name + '.png'
# plt.show()
plt.savefig(filename)
return (name, filename)
示例2: plot_all
def plot_all():
font = {'family': 'serif',
'weight': 'normal',
'size': 12,
}
plt.rc('font', **font)
data = DataReader('dyn_spin.txt')
ts = data['time']
fig = plt.figure(figsize=(5, 4))
mx = data['m_x']
my = data['m_y']
mz = data['m_z']
plt.plot(ts, mx, '-', label='mx', color='b')
plt.plot(ts, my, '-', label='my', color='g')
plt.plot(ts[::6], mz[::6],'.-', label='mz', color='r')
plt.legend(bbox_to_anchor=[0.8, 0.8], shadow=True, frameon=True)
#plt.xlim([0, 1.01])
plt.legend()
plt.xlabel('Time')
plt.ylabel('m')
plt.tight_layout()
fig.savefig('m_ts.pdf')
示例3: plot
def plot(filename):
import os
from matplotlib.pyplot import clf, tricontour, tricontourf, \
gca, savefig, rc, minorticks_on
if not os.path.exists(filename):
return -1
rc('text', usetex=True)
clf()
x, y, tri, ux, uy = load_velocity(filename)
tricontourf(x, y, tri, ux, 16)
tricontour(x, y, tri, ux, 16, linestyles='-',
colors='black', linewidths=0.5)
minorticks_on()
gca().set_aspect('equal')
gca().tick_params(direction='out', which='both')
gca().set_xticklabels([])
gca().set_yticklabels([])
name, _ = os.path.splitext(filename)
name = os.path.basename(name)
savefig('{0}.png'.format(name), dpi=300, bbox_inches='tight')
savefig('{0}.pdf'.format(name), bbox_inches='tight')
示例4: dim_sensitivity_plot
def dim_sensitivity_plot(x, Y, fname, show_legend=True):
plt.rc('text', usetex=True)
plt.rc('font', family='serif')
plt.figure(figsize=(3, 3))
plt.xlabel('$d$', size=FONTSIZE)
plt.ylabel('ROC AUC', size=FONTSIZE)
plt.set_cmap('Set2')
lines = []
for i, label in enumerate(KEYS):
line_data = Y.get(label)
if line_data is None:
continue
line, = plt.plot(x, line_data, label=label, marker=MARKERS[i],
markersize=0.5 * FONTSIZE, color=COLORS[i])
lines.append(line)
if show_legend:
plt.legend(handles=lines)
plt.legend(loc='lower right')
plt.xscale('log', basex=2)
plt.xticks(x, [str(y) for y in x], size=FONTSIZE)
plt.yticks(size=FONTSIZE)
plt.tight_layout()
plt.savefig(fname)
示例5: boxplotThem
def boxplotThem(dataToPlot,title):
means = [np.mean(item) for item in dataToPlot]
fig = plt.figure(1, figsize=(9,6))
ax = fig.add_subplot(111)
plt.rc('text', usetex=True)
plt.rc('font', family='serif')
for i in range(25):
print('length ',str(i+1))
for item in dataToPlot[i]:
ax.scatter(i+1,item)
ax.plot(list(range(1,26)),means,linewidth=4,color='r')
ax.set_xticks([1,5,10,15,20,25])
ax.set_xticklabels([r"$1",r"$5$",r"$10$",r"$15$",r"$20$",r"$25$"],fontsize = 25)
ax.set_yscale('log')
ax.set_yticks([0.00000001,0.000001,0.0001,0.01,1])
ax.xaxis.set_tick_params(width=1.5)
ax.yaxis.set_tick_params(width=1.5)
ax.set_yticklabels([r"$10^{-8}$",r"$10^{-6}$",r"$10^{-4}$",r"$10^{-2}$",r"$1$"],fontsize = 25)
ax.get_yaxis().get_major_formatter().labelOnlyBase = False
ax.set_ylabel('relative population',fontsize = 30)
ax.set_xlabel(r'length',fontsize = 30)
ax.set_xlim(0,26)
ax.set_ylim(0.00000005)
plt.suptitle(title,fontsize=25)
plt.savefig(r.outputDir+'distr.png')
示例6: plot
def plot(self, debug = False):
"""plot figures for population, nuisance parameters"""
# first figure out what scheme is used
self.list_scheme()
# next get MABR sampling done
self.MBAR_analysis()
# load in precomputed P and dP from MBAR analysis
pops0, pops1 = self.P_dP[:,0], self.P_dP[:,self.K-1]
dpops0, dpops1 = self.P_dP[:,self.K], self.P_dP[:,2*self.K-1]
t0 = self.traj[0]
t1 = self.traj[self.K-1]
# Figure Plot SETTINGS
label_fontsize = 12
legend_fontsize = 10
fontfamily={'family':'sans-serif','sans-serif':['Arial']}
plt.rc('font', **fontfamily)
# determine number of row and column
if (len(self.scheme)+1)%2 != 0:
c,r = 2, (len(self.scheme)+2)/2
else:
c,r = 2, (len(self.scheme)+1)/2
plt.figure( figsize=(4*c,5*r) )
# Make a subplot in the upper left
plt.subplot(r,c,1)
plt.errorbar( pops0, pops1, xerr=dpops0, yerr=dpops1, fmt='k.')
plt.hold(True)
plt.plot([1e-6, 1], [1e-6, 1], color='k', linestyle='-', linewidth=2)
plt.xlim(1e-6, 1.)
plt.ylim(1e-6, 1.)
plt.xlabel('$p_i$ (exp)', fontsize=label_fontsize)
plt.ylabel('$p_i$ (sim+exp)', fontsize=label_fontsize)
plt.xscale('log')
plt.yscale('log')
# label key states
plt.hold(True)
for i in range(len(pops1)):
if (i==0) or (pops1[i] > 0.05):
plt.text( pops0[i], pops1[i], str(i), color='g' )
for k in range(len(self.scheme)):
plt.subplot(r,c,k+2)
plt.step(t0['allowed_'+self.scheme[k]], t0['sampled_'+self.scheme[k]], 'b-')
plt.hold(True)
plt.xlim(0,5)
plt.step(t1['allowed_'+self.scheme[k]], t1['sampled_'+self.scheme[k]], 'r-')
plt.legend(['exp', 'sim+exp'], fontsize=legend_fontsize)
if self.scheme[k].find('cs') == -1:
plt.xlabel("$\%s$"%self.scheme[k], fontsize=label_fontsize)
plt.ylabel("$P(\%s)$"%self.scheme[k], fontsize=label_fontsize)
plt.yticks([])
else:
plt.xlabel("$\sigma_{%s}$"%self.scheme[k][6:],fontsize=label_fontsize)
plt.ylabel("$P(\sigma_{%s})$"%self.scheme[k][6:],fontsize=label_fontsize)
plt.yticks([])
plt.tight_layout()
plt.savefig(self.picfile)
示例7: PlotData
def PlotData(Stock,buyselldata):
plt.rc('axes', grid=True)
plt.rc('grid', color='0.75', linestyle='-', linewidth=0.5)
textsize = 9
left, width = 0.1, 0.8
rect1 = [left, 0.1, width, 0.9]
fig = plt.figure(facecolor='white')
axescolor = '#f6f6f6' # the axies background color
ax1 = fig.add_axes(rect1, axisbg=axescolor) #left, bottom, width, height
### plot the relative strength indicator
prices = Stock.close
fillcolor = 'darkgoldenrod'
plt.plot(Stock.date, prices, color=fillcolor)
for i in buyselldata[0]:
plt.plot(Stock.date[i],prices[i],'bo')
for i in buyselldata[1]:
plt.plot(Stock.date[i],prices[i],'rx')
plt.show()
示例8: make_rainbow
def make_rainbow(a=0.75, b=0.2, name='custom_rainbow', register=False):
"""
Use a=0.7, b=0.2 for a darker end.
when 0.5<=a<=1.5, should have b >= (a-0.5)/2 or 0 <= b <= (a-1)/3
when 0<=a<=0.5, should have b >= (0.5-a)/2 or 0<= b<= -a/3
to assert the monoique
To show the parameter dependencies interactively in notebook
```
%matplotlib inline
from ipywidgets import interact
def func(a=0.75, b=0.2):
cmap = gene_rainbow(a=a, b=b)
show_cmap(cmap)
interact(func, a=(0, 1, 0.05), b=(0.1, 0.5, 0.05))
```
"""
def gfunc(a, b, c=1):
def func(x):
return c * np.exp(-0.5 * (x - a)**2 / b**2)
return func
cdict = {"red": gfunc(a, b),
"green": gfunc(0.5, b),
"blue": gfunc(1 - a, b)
}
cmap = mpl.colors.LinearSegmentedColormap(name, cdict)
if register:
plt.register_cmap(cmap=cmap)
plt.rc('image', cmap=cmap.name)
return cmap
示例9: make_x_plot
def make_x_plot():
from numpy import linspace
from matplotlib import pyplot as pl
pl.rc('text', usetex=True)
pl.rc('font', family='serif')
lamdas = [-1,-0.9,-0.7,0,0.7,0.9,1]
for lam in lamdas:
plotx(lam,0)
plotx(lam,1,linestyle='k--')
plotx(lam,2)
plotx(lam,3,linestyle='k--')
pl.axvline(x=1,color='k')
pl.xlabel(r'$$x$$',fontsize=16)
pl.ylabel(r'$$T$$',fontsize=16)
pl.text(0.0, 1.5, r'$$M=0$$', bbox=dict(facecolor='white', alpha=1))
pl.text(0.0, 4.7, r'$$M=1$$', bbox=dict(facecolor='white', alpha=1))
pl.text(0.0, 8.0, r'$$M=2$$', bbox=dict(facecolor='white', alpha=1))
pl.text(0.5, 4, r'hyperbolic')
pl.text(1.2, 4, r'elliptic')
pl.annotate(r'$$\lambda = 1$$', xy=(-0.25, 1.1), xytext=(-0.8, 0.2),
arrowprops=dict(facecolor='black', shrink=0.15, width=1,headwidth=5),
)
pl.annotate(r'$$\lambda = -1$$', xy=(0.5, 2.0), xytext=(0.7, 3.0),
arrowprops=dict(facecolor='black', shrink=0.15, width=1,headwidth=5),
)
示例10: prepare_figure
def prepare_figure(obj_area):
# create new figure
#fig = Figure() # old version, does not work for the stream plot
## Turn interactive plotting off
#plt.ioff()
fig = plt.figure() # needs a DISPLAY environment variable (simulated here with mpl.use('Agg'))
# define size of image
nx = obj_area.x_size
ny = obj_area.y_size
# canvas figure
canvas = FigureCanvas(fig)
# get dots per inch of the screen
DPI = fig.get_dpi()
# print "DPI", DPI
fig.set_size_inches(nx/float(DPI),ny/float(DPI))
# set fonts to bold
plt.rc('font', weight='bold')
# get axis object
ax = fig.add_subplot(111, aspect='equal')
## eliminates margins totally
fig.subplots_adjust(left=0.0,right=1.0,bottom=0.0,top=1.0, wspace=0, hspace=0)
# set limits of the axis
ax.set_xlim(0, nx)
ax.set_ylim(0, ny)
# set transparent backgroud
fig.patch.set_alpha(0.0) # transparent outside of diagram
ax.set_axis_bgcolor([1,0,0,0]) # transparent color inside diagram
return fig, ax
示例11: plot
def plot(results, total_a, total_b, label_a, label_b, outputFile=None):
all_rules = sorted(results, key=lambda v: (-len(v['item']), round(abs(v['count_a'] / total_a - v['count_b'] / total_b), 2), round(v['count_a'] / total_a, 2)))
values_a = [100 * rule['count_a'] / total_a for rule in all_rules]
values_b = [100 * rule['count_b'] / total_b for rule in all_rules]
plt.rc('figure', autolayout=True)
plt.rc('font', size=22)
fig, ax = plt.subplots(figsize=(24, 18))
index = range(len(all_rules))
bar_width = 0.35
if label_a.startswith('_'):
label_a = ' ' + label_a
if label_b.startswith('_'):
label_b = ' ' + label_b
bar_a = plt.barh(index, values_a, bar_width, color='b', label=label_a)
bar_b = plt.barh([i + bar_width for i in index], values_b, bar_width, color='r', label=label_b)
plt.xlabel('Support')
plt.ylabel('Rule')
plt.title('Most interesting deviations')
plt.yticks([i + bar_width for i in index], [rule_to_str(rule['item']) for rule in all_rules])
if len(all_rules) > 0:
plt.legend(handles=[bar_b, bar_a], loc='best')
if outputFile is not None:
plt.savefig(outputFile)
else:
plt.show()
plt.close(fig)
示例12: plot_bars
def plot_bars(groups, group_labels, legends, ylabel, yscale=None):
N = len(group_labels)
ind = np.arange(N) # the x locations for the groups
width = 0.1 # the width of the bars
plt.rc('xtick', labelsize=12)
plt.rc('ytick', labelsize=12)
fig = plt.figure(figsize=(14,7), dpi=300)
ax = fig.add_subplot(111)
colors = ['b', 'r', 'y', 'g', 'm']
rects = []
i = 0
for group in groups:
rects.append(ax.bar(ind + ((i + 3) * 1.0 * width), group, width, bottom=10**-3, color=colors[i]))
i += 1
ax.set_xticks(ind+0.5+width)
ax.set_xticklabels( group_labels )
box = ax.get_position()
ax.set_position([box.x0, box.y0, box.width * 0.95, box.height])
ax.legend(rects, legends, loc='center left', bbox_to_anchor=(1, 0.5), prop={'size':14})
if yscale != None:
plt.yscale(yscale)
plt.ylabel(ylabel, fontsize=14)
return plt
示例13: printEnrichment
def printEnrichment(controlVsTestTupleList, proteinGroupsDataFrame, go_to_SGDID,sgdidList):
f, axarr = plt.subplots(4, 2)
f.subplots_adjust(hspace = 0.75)
i = 0
j = 0
font ={'family':'normal', 'weight':'bold', 'size':8}
plt.rc('font', **font)
for (control, test) in controlVsTestTupleList:
e1, n1 = calculate_enrichment(test, proteinGroupsDataFrame, go_to_SGDID,sgdidList)
e0, n0 = calculate_enrichment(control, proteinGroupsDataFrame, go_to_SGDID,sgdidList)
e0list, e1list, egoidlist, emaxlist = checkGoLengths(e0, e1)
n0list, n1list, ngoidlist, nmaxlist = checkGoLengths(n0, n1)
maxlist = [emaxlist[0], emaxlist[1], nmaxlist[0], nmaxlist[1]]
axarr[i, j].plot(e0list, e1list, 'b.')
axarr[i, j].plot(n0list, n1list, 'r.')
axarr[i, j].set_title(control +'vs'+ test, fontsize=8)
axarr[i, j].set_xlabel('control')
axarr[i, j].set_ylabel('test')
axarr[i, j].set_xlim([0, max(maxlist)])
axarr[i, j].set_ylim([0, max(maxlist)])
"""index = 0
#to add all go ids to plot
for xy in zip(e0list, e1list):
axarr[i, j].annotate('%s' % egoidlist[index], xy=xy, textcoords='data')
index+=1"""
if j == 1:
i+=1
j=0
else:
j+=1
plt.show()
示例14: features_pca_classified
def features_pca_classified(fscaled, labels_true, labels_predict, axes=None,
algorithm="pca"):
if algorithm == 'pca':
pc = PCA(n_components=2)
fscaled_trans = pc.fit(fscaled).transform(fscaled)
elif algorithm == "tsne":
fscaled_trans = TSNE(n_components=2).fit_transform(fscaled)
else:
raise AlgorithmUnrecognizedException("Not recognizing method of "+
"dimensionality reduction.")
sns.set_style("whitegrid")
plt.rc("font", size=24, family="serif", serif="Computer Sans")
plt.rc("axes", titlesize=20, labelsize=20)
plt.rc("text", usetex=True)
plt.rc('xtick', labelsize=20)
plt.rc('ytick', labelsize=20)
# make a Figure object
if axes is None:
fig, axes = plt.subplots(1,2,figsize=(16,6), sharey=True)
ax1, ax2 = axes[0], axes[1]
ax1 = plotting.scatter(fscaled_trans, labels_true, ax=ax1)
# second panel: physical labels:
ax2 = plotting.scatter(fscaled_trans, labels_predict, ax=ax2)
plt.tight_layout()
return ax1, ax2
示例15: plotcurve
def plotcurve(xax,f1,f2,ct):
fig, axes = plt.subplots(nrows=4, ncols=1, sharex=True)
plt.minorticks_on()
fig.subplots_adjust(hspace = 0.001)
plt.rc('font', family='serif',serif='Times')
y_formatter = matplotlib.ticker.ScalarFormatter(useOffset=False)
axes[0].plot(xax,f1[0],'D-',c='k',mec='b',fillstyle='none')
axes[0].plot(xax,f2[0],'o-',c='g',mec='k',fillstyle='none')
axes[0].set_ylabel(r'$raw$ $RMS$',fontsize=13)
axes[0].yaxis.set_major_formatter(y_formatter)
axes[0].yaxis.set_major_locator(MaxNLocator(prune='both',nbins=5))
axes[1].plot(xax,f1[1],'D-',c='k',mec='b',fillstyle='none')
axes[1].plot(xax,f2[1],'o-',c='g',mec='k',fillstyle='none')
axes[1].set_ylabel(r'$frames$ $RMS$',fontsize=13)
axes[1].yaxis.set_major_formatter(y_formatter)
axes[1].yaxis.set_major_locator(MaxNLocator(prune='both',nbins=5))
axes[2].plot(xax,f1[2],'D-',c='k',mec='b',fillstyle='none')
axes[2].plot(xax,f2[2],'o-',c='g',mec='k',fillstyle='none')
axes[2].set_ylabel(r'$\sigma-clipped$',fontsize=13)
axes[2].yaxis.set_major_formatter(y_formatter)
axes[2].yaxis.set_major_locator(MaxNLocator(prune='both',nbins=5))
axes[3].plot(xax,f1[3],'D-',c='k',mec='b',fillstyle='none',label='Hard')
axes[3].plot(xax,f2[3],'o-',c='g',mec='k',fillstyle='none',label='Soft')
axes[3].set_ylabel(r'$\sigma$ $clipped$ $RMS$',fontsize=13)
axes[3].set_xlabel(r'$aperture$ $(pixels)$',fontsize=13)
axes[3].yaxis.set_major_formatter(y_formatter)
axes[3].yaxis.set_major_locator(MaxNLocator(prune='both',nbins=5))
axes[3].legend(numpoints=1)
plt.savefig('paneltest/'+str(ct)+'updchanges.png',bbox_inches='tight',dpi=200)