本文整理汇总了Python中matplotlib.font_manager.FontProperties.set_size方法的典型用法代码示例。如果您正苦于以下问题:Python FontProperties.set_size方法的具体用法?Python FontProperties.set_size怎么用?Python FontProperties.set_size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.font_manager.FontProperties
的用法示例。
在下文中一共展示了FontProperties.set_size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: legend
# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_size [as 别名]
def legend(labels, ax=None, im=None, handles=None, bbox=None,
loc='upper center', ncol=None):
"""Adds legend to plot.
"""
if ax == None:
ax = pylab.gca()
fontP = FontProperties()
fontP.set_size('small')
#
if bbox == None:
bbox = (0.5, -0.05)
if ncol == None:
ncol = int(round(len(labels)/2))
if im == None:
if handles == None:
ax.legend(labels, loc=loc, bbox_to_anchor=bbox,
ncol=ncol, prop=fontP)
else:
ax.legend(handles, labels, loc=loc, bbox_to_anchor=bbox,
ncol=ncol, prop=fontP)
else:
_proxy, _legend = [], []
for lc, pc in zip(labels, im.collections):
if lc != None:
_proxy.append(pylab.Rectangle((0, 0), 1, 1,
fc=pc.get_facecolor()[0], hatch=pc.get_hatch()))
_legend.append(lc)
ax.legend(_proxy, _legend, loc='upper center',
bbox_to_anchor=bbox, ncol=int(round(len(labels)/2)),
prop=fontP)
#
return
示例2: plot_all
# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_size [as 别名]
def plot_all(wells, errors=None, do_legend=True, legend_position=0.8):
"""Plots all of the timecourses in the dict.
Parameters
----------
wells : dict of timecourse data of the type returned by read_wallac.
"""
for wellname, wellval in wells.iteritems():
if errors is None:
plot(wellval[TIME], wellval[VALUE], label=wellname)
else:
errorbar(wellval[TIME], wellval[VALUE],
yerr=errors[wellname][VALUE], label=wellname)
# Label the axes and add a legend
xlabel('Time') # TODO: automatically determine seconds or minutes, etc.
ylabel('Value')
if do_legend:
fontP = FontProperties()
fontP.set_size('small')
ax = gca()
box = ax.get_position()
ax.set_position([box.x0, box.y0, box.width * legend_position,
box.height])
legend(loc='upper left', prop=fontP, ncol=1, bbox_to_anchor=(1, 1),
fancybox=True, shadow=True)
示例3: plot_np_simple
# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_size [as 别名]
def plot_np_simple(x_labels, x_values_np, y_values_np, x_label, y_label, title, nb_x_labels, style):
x = np.arange(len(y_values_np))
fig, ax = plt.subplots()
if style != None:
ax.plot(x_values_np, y_values_np, style)
else:
ax.plot(x_values_np, y_values_np)
plt.xlabel(x_label)
plt.ylabel(y_label)
plt.title(title)
fontP = FontProperties()
fontP.set_size('small')
plt.legend(loc='lower right', prop=fontP)
if x_labels != None:
labels = np.array(x_labels)
jump_step = len(labels)/nb_x_labels
label_indexes = np.arange(1,len(labels),jump_step)
for (X, Z) in zip(x[label_indexes], labels[label_indexes]):
ax.annotate('{}'.format(Z), xy=(X,0), xytext=(X, (-0.1*y_max)), rotation=90, ha='center', size=10,
textcoords='data')
fig.tight_layout(pad=4)
plt.draw()
示例4: _show_3d_plot
# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_size [as 别名]
def _show_3d_plot(self):
'''
Shows the plot using pylab. Usually I won't do imports in methods,
but since plotting is a fairly expensive library to load and not all
machines have matplotlib installed, I have done it this way.
'''
import matplotlib.pyplot as plt
import mpl_toolkits.mplot3d.axes3d as p3
from matplotlib.font_manager import FontProperties
fig = plt.figure()
ax = p3.Axes3D(fig)
font = FontProperties()
font.set_weight('bold')
font.set_size(20)
(lines, labels, unstable) = self.pd_plot_data
count = 1
newlabels = list()
for x, y, z in lines:
ax.plot(x, y, z, 'bo-', linewidth=3, markeredgecolor='b', markerfacecolor='r', markersize=10)
for coords in sorted(labels.keys()):
entry = labels[coords]
label = entry.name
if len(entry.composition.elements) == 1:
# commented out options are only for matplotlib 1.0. Removed them so that most ppl can use this class.
ax.text(coords[0], coords[1], coords[2], label)#, horizontalalignment=halign, verticalalignment=valign, fontproperties=font)
else:
ax.text(coords[0], coords[1], coords[2], str(count))#, horizontalalignment=halign, verticalalignment=valign, fontproperties=font)
newlabels.append(str(count) + " : " + label)
count += 1
plt.figtext(0.01, 0.01, '\n'.join(newlabels))
ax.axis('off')
plt.show()
示例5: plot_gradient_over_time
# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_size [as 别名]
def plot_gradient_over_time(points, get_grad_over_time):
fig = plt.figure(figsize=(6.5, 4))
# Remove the plot frame lines. They are unnecessary chartjunk.
ax = plt.subplot(111)
ax.spines["top"].set_visible(False)
ax.spines["right"].set_visible(False)
# ax.xaxis.set_major_locator(plt.MultipleLocator(1.0))
# ax.xaxis.set_minor_locator(plt.MultipleLocator(0.1))
# ax.yaxis.set_major_locator(plt.MultipleLocator(1.0))
# ax.yaxis.set_minor_locator(plt.MultipleLocator(0.1))
# ax.grid(which='major', axis='x', linewidth=0.75, linestyle='-', color='0.75')
# ax.grid(which='minor', axis='x', linewidth=0.25, linestyle='-', color='0.75')
# ax.grid(which='major', axis='y', linewidth=0.75, linestyle='-', color='0.75')
# ax.grid(which='minor', axis='y', linewidth=0.25, linestyle='-', color='0.75')
ax.grid(b=True, which='major', linewidth=0.75, linestyle=':', color='0.75')
ax.yaxis.set_ticks_position('none')
ax.xaxis.set_ticks_position('none')
for wx, wRec, c in points:
grad_over_time = get_grad_over_time(wx, wRec)
x = np.arange(1, grad_over_time.shape[1]+1, 1)
plt.plot(x, np.sum(grad_over_time, axis=0), c+'.-', label='({0}, {1})'.format(wx, wRec), linewidth=1, markersize=8)
plt.xlim(1, grad_over_time.shape[1])
plt.xticks(x)
plt.gca().invert_xaxis()
plt.yscale('symlog')
plt.yticks([10**8, 10**6, 10**4, 10**2, 0, -10**2, -10**4, -10**6, -10**8])
plt.xlabel('time k')
plt.ylabel('gradient ')
plt.title('Unstability of gradient in backward propagation.\n(backpropagate from left to right)')
leg = plt.legend(loc='center left', bbox_to_anchor=(1, 0.5), frameon=False, numpoints=1)
leg_font = FontProperties()
leg_font.set_size('x-large')
leg.set_title('$(w_x, w_{rec})$', prop=leg_font)
示例6: plotProfile
# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_size [as 别名]
def plotProfile(plotname, data):
''' Plot a profile of the colors'''
dtc=None
if args.window:
dt=numpy.transpose(data)
for i in range(dt.shape[0]):
dt[i]=movingAverage(dt[i], args.window)
dtc=numpy.transpose(dt)
else:
dtc=data
fontP = FontProperties()
fontP.set_size('small')
fig = plt.figure()
ax = plt.subplot(111)
ax.plot(dtc)
#ax.set_xticklabels(xlabels, rotation=45, fontproperties=fontP)
#ax.set_xlabel('Image number in the series')
ax.set_ylabel('Reef colors')
box = ax.get_position()
#ax.set_position([box.x0, box.y0 + box.height * 0.1, box.width, box.height * 0.9])
#ax.set_position([box.x0, box.y0 + box.height * 0.1, box.width, box.height])
ax.set_position([box.x0, box.y0 + box.height * 0.1, box.width, box.height *0.85])
header=["blue", "green", "red"]
ax.legend((header), loc='upper center', bbox_to_anchor=(0.5, -0.10), ncol=4, prop=fontP)
fig.savefig(plotname)
示例7: create_plot
# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_size [as 别名]
def create_plot(plot_title, datasets, offset, count, output_path):
x = 0
for dataset_path in datasets:
first,average,conf = statistics(dataset_path, offset, count)
b_first = plt.bar(x, first, 0.5, color='b')
x += 0.5
b_average = plt.bar(x, average, 0.5, color='r', yerr=conf, ecolor='black')
x += 1.5
plt.title("benchmark: " + plot_title)
plt.xlabel('Dataset', fontsize=12)
plt.ylabel('Time', fontsize=12)
plt.xticks([0.5, 2.5, 4.5, 6.5, 8.5], ['10', '100', '1000', '10000', '100000'], rotation='horizontal')
# Create graph legend
fontP = FontProperties()
fontP.set_size('small')
plt.legend([b_first, b_average], \
('first query time', 'average time of other queries'), \
prop=fontP, loc='upper center', bbox_to_anchor=(0.5, -0.05), fancybox=True, shadow=True, ncol=2)
# Plot to file
plt.savefig(output_path)
plt.clf()
示例8: make_cross_plot
# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_size [as 别名]
def make_cross_plot(wac_df, clm_df):
'''
x = 320/415
y = 950/750
'''
for index_name in wac_df.index:
roi_name = index_name[:-4]
x = wac_df.loc[index_name].values
y = clm_df.loc[roi_name+'_clm'].values
x_data = np.ma.masked_array(x[0],np.isnan(x[0]))
y_data = np.ma.masked_array(y[0],np.isnan(y[0]))
print roi_name, np.mean(x_data), np.mean(y_data), np.std(x_data), np.std(y_data)
plt.errorbar(np.mean(x_data), np.mean(y_data), xerr=np.std(x_data),
yerr=np.std(y_data), marker='o', label=(roi_name),
c=colorloop.next())
rois_rough = pd.read_csv('/home/sbraden/imps_ratio_rough.csv', index_col=0)
rois_mare = pd.read_csv('/home/sbraden/imps_ratio_mare.csv', index_col=0)
for roi_name in rois_rough.index:
ratio = rois_rough.loc[roi_name].values
plt.scatter(ratio[1], ratio[0], marker='s', c='blue')
for roi_name in rois_mare.index:
ratio = rois_mare.loc[roi_name].values
plt.scatter(ratio[1], ratio[0], marker='s', c='red')
fontP = FontProperties()
fontP.set_size('small')
plt.legend(loc='lower right', prop=fontP, numpoints=1)
plt.xlabel('320/415 nm WAC ratio', fontsize=14)
plt.ylabel('950/750 nm CLEM ratio', fontsize=14)
plt.savefig('lunar_roi_cross_plot.png', dpi=300)
plt.close()
示例9: topic_distribution
# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_size [as 别名]
def topic_distribution(name = None, study = None, order = None, **options):
'''Given a model p_z,p_w_z,p_d_z, we can plot the document's distribution
using p(z|d) = normalized((p(d|z)*p(z))) '''
m = microbplsa.MicrobPLSA()
m.open_model(name = name, study = study, **options) #get model from the results file
#return document's distribution
p_z_d = m.model.document_topics()
Z,N =p_z_d.shape #number of samples
if order is not None:
p_z_d = p_z_d[:,order]
n = np.arange(N)
width = 25.0/float(N) #scale width of bars by number of samples
p = [] #list of plots
colors = plt.cm.rainbow(np.linspace(0, 1, Z))
Lab = Labelling(m, ignore_continuous = False)
Lab.metadata(non_labels = ['BarcodeSequence'])
R = Lab.correlate()
labels_r = Lab.assignlabels(R,num_labels = 1)
labels, r = zip(*labels_r)
labels = [l.replace('(','\n(') for l in labels]
#sort and organize labels and topics so they are always plotted in the same order
labelsUnsorted = zipper(labels,range(0,Z))
labelsUnsorted.sort()
labels, Zrange = zip(*labelsUnsorted)
Zrange = list(Zrange)
p.append(plt.bar(n, p_z_d[Zrange[0],:], width, color=colors[0], linewidth = 0))
height = p_z_d[Zrange[0],:]
for i,z in enumerate(Zrange[1:]):
p.append(plt.bar(n, p_z_d[z,:], width, color=colors[i+1], bottom=height, linewidth = 0))
height += p_z_d[z,:]
plt.ylabel('Probability P(z|d)')
plt.xlabel('Sample')
plt.title('Sample\'s topic distribution')
#plt.xticks(np.arange(0,width/2.0,N*width), ['S'+str(n) for n in range(1,N)])
topiclegend = ['Topic' + str(Zrange[labels.index(l)]+1) + ': '+ l + '\n ('+ str(r[Zrange[labels.index(l)]]) + ')' for l in labels]
fontP = FontProperties()
if N >60:
fontP.set_size('xx-small')
else: fontP.set_size('small')
ax = plt.subplot(111)
ratio = float(N)*0.5
ax.set_aspect(ratio)
ax.tick_params(axis = 'x', colors='w') #remove tick labels by setting them the same color as background
box = ax.get_position()
ax.set_position([box.x0, box.y0, 0.5, box.height])
if order is not None:
plt.xticks(n, order, size = 'xx-small')
if Z > 12:
columns = 2
else: columns = 1
plt.legend(p, topiclegend, prop = fontP, title = 'Topic Label', loc='center left', bbox_to_anchor=(1, 0.5), ncol = columns)
return plt
示例10: compile_scatter_plot_3d
# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_size [as 别名]
def compile_scatter_plot_3d(args):
bytes = args['tp_sizes'][0]
tracers = args['tracers']
res_dir = '/home/mogeb/git/benchtrace/trace-client/'
values = defaultdict(list)
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
fname = res_dir + 'none_' + str(bytes) + 'bytes_1process.hist'
with open(fname, 'r') as f:
legend = f.readline()
legend = legend.split(',')
i = 0
for tracer in tracers:
fname = res_dir + tracer + '_' + str(bytes) + 'bytes_1process.hist'
values[tracer] = np.genfromtxt(fname, delimiter=',', skip_header=1, names=legend,
dtype=None)
fontP = FontProperties()
fontP.set_size('small')
for tracer in tracers:
ax.scatter(values[tracer]['cache_misses'], values[tracer]['Instructions'],
values[tracer]['latency'])
plt.title('Latency according to cache_misses and instructions')
ax.set_xlabel('cache_misses')
ax.set_ylabel('Instructions')
ax.set_zlabel('latency')
plt.legend(prop=fontP)
plt.show()
示例11: main
# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_size [as 别名]
def main():
# Write a part to put image directories into "groups"
source_dirs = [
'/home/sbraden/400mpp_15x15_clm_wac/mare/',
'/home/sbraden/400mpp_15x15_clm_wac/pyro/',
'/home/sbraden/400mpp_15x15_clm_wac/imps/',
'/home/sbraden/400mpp_15x15_clm_wac/mare_immature/'
]
for directory in source_dirs:
print directory
groupname = os.path.split(os.path.dirname(directory))[1]
print groupname
# read in LROC WAC images
wac_img_list = iglob(directory+'*_wac.cub')
# read in Clementine images
clm_img_list = iglob(directory+'*_clm.cub')
make_cloud_plot(wac_img_list, colorloop.next(), groupname)
fontP = FontProperties()
fontP.set_size('small')
#plt.legend(loc='upper left', fancybox=True, prop=fontP, scatterpoints=1)
#plt.axis([0.70, 0.86, 0.90, 1.15],fontsize=14)
plt.axis([0.60, 0.90, 0.90, 1.20],fontsize=14)
plt.axes().set_aspect('equal')
# THIS next line does not get called:
plt.margins(0.20) # 4% add "padding" to the data limits before they're autoscaled
plt.xlabel('WAC 320/415 nm', fontsize=14)
plt.ylabel('CLM 950/750 nm', fontsize=14)
plt.savefig('lunar_roi_cloud_plot.png', dpi=300)
plt.close()
示例12: compile_lttng_subbuf
# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_size [as 别名]
def compile_lttng_subbuf(args):
res_dir = '/home/mogeb/git/benchtrace/trace-client/'
tp_sizes = args['tp_sizes']
nprocesses = args['nprocesses']
tracer = 'lttng'
buf_sizes_kb = args['buf_sizes_kb']
perc = 0.90
for tp_size in tp_sizes:
percentiles = []
for buf_size_kb in buf_sizes_kb:
for tp_size in tp_sizes:
# fname = res_dir + tracer + '_' + str(byte_size) + 'bytes_' + nprocess + 'process.hist'
fname = tracer + '_' + str(tp_size) + 'bytes_' + buf_size_kb\
+ 'kbsubbuf_1_process.hist'
with open(fname, 'r') as f:
legend = f.readline()
legend = legend.split(',')
values = np.genfromtxt(fname, delimiter=',', skip_header=1, names=legend, dtype=None,
invalid_raise=False)
# percentiles.append(np.percentile(values['latency'], perc))
percentiles.append(np.average(values['latency']))
plt.plot(buf_sizes_kb, percentiles, 'o-', label=tracer, color=tracers_colors[tracer])
plt.title(str(int(perc * 100)) + 'th percentiles for the cost of a tracepoint according to'
'payload size')
plt.xlabel('Subbuffer size in kb')
plt.ylabel('Time in ns')
fontP = FontProperties()
fontP.set_size('small')
# imgname = 'pertp/90th_' + nprocess + 'proc_' + str(args['buf_size_kb']) + 'subbuf_kb'
plt.legend()
plt.show()
示例13: compile_scatter_plot_ICL
# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_size [as 别名]
def compile_scatter_plot_ICL(args):
bytes = args['tp_sizes'][0]
tracers = args['tracers']
res_dir = '/home/mogeb/git/benchtrace/trace-client/'
values = defaultdict(list)
cpi = defaultdict(list)
fname = res_dir + 'none_' + str(bytes) + 'bytes_1process.hist'
with open(fname, 'r') as f:
legend = f.readline()
legend = legend.split(',')
for tracer in tracers:
fname = res_dir + tracer + '_' + str(bytes) + 'bytes_1process.hist'
values[tracer] = np.genfromtxt(fname, delimiter=',', skip_header=1, names=legend, dtype=int)
for tracer in tracers:
for i in range(0, len(values[tracer])):
cpi[tracer].append(values[tracer]['CPU_cycles'][i] / values[tracer]['Instructions'][i])
for tracer in tracers:
plt.scatter(values[tracer]['L1_misses'], cpi[tracer], s=values[tracer]['latency']*0.8,
color=tracers_colors[tracer], alpha=0.3, label=tracer)
fontP = FontProperties()
fontP.set_size('small')
plt.title('Latency according to CPI and L1 misses')
plt.xlabel('L1_misses')
plt.ylabel('CPI')
plt.legend(prop=fontP)
plt.show()
示例14: plot
# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_size [as 别名]
def plot(X, Y, Graphs, Type, State_State):
colors = iter(cm.rainbow(np.linspace(0, 1, len(Graphs))))
if Type == 1:
XTitle = 'delta'
elif Type == 2:
XTitle = 'epsilon'
Y = Y.T
else:
print "Incorrect plot type, correct plottypes are 1 for row by columns and 2 for columns by rows."
exit()
Title = "Plot of rate " + str(State_State) + " for different values of " + XTitle
#not sure if this works
plt.figure(Title)
for x in range(len(Graphs)):
plt.plot(X, Y[x], label= str(Graphs[x]), color=next(colors))
plt.ylabel('rate')
plt.xlabel(XTitle)
plt.grid(True)
plt.title(Title)
fontP = FontProperties()
fontP.set_size('small')
plt.legend(bbox_to_anchor=(1.01, 1), loc='upper left', borderaxespad=0., prop = fontP)
FileName = 'rate_' + str(State_State) + '_' + XTitle +'.png'
plt.savefig(FileName)
示例15: plot_markers
# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_size [as 别名]
def plot_markers(data, x_base, name, map, xoff_sgn, width, off_fac,
markersize):
maxD = 0
ds = {}
used = []
font = FontProperties()
font.set_family('sans-serif')
font.set_size(10)
for (kind, subkind, dimval) in data:
try:
symb, lab = map[kind][subkind]
except KeyError:
raise KeyError("Invalid key for %s symbols"%name)
used.append((kind, subkind))
try:
ds[dimval] += 1
x_off = xoff_sgn*width*off_fac*(ds[dimval]-1)
except KeyError:
ds[dimval] = 1
x_off = 0
plot([x_base+x_off], [dimval], symb, markersize=markersize)
# hack tweaks
## if lab=='C':
## x_off -= width/15
if lab=='A':
x_off += width/30
text(x_base+x_off-width*.15, dimval-width*2., lab,
fontproperties=font)
if dimval > maxD:
maxD = dimval
return ds, maxD, used