本文整理汇总了Python中matplotlib.font_manager.FontProperties.copy方法的典型用法代码示例。如果您正苦于以下问题:Python FontProperties.copy方法的具体用法?Python FontProperties.copy怎么用?Python FontProperties.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.font_manager.FontProperties
的用法示例。
在下文中一共展示了FontProperties.copy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_defaults
# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import copy [as 别名]
def set_defaults(self):
self.zoom_x = 0
self.zoom_y = 0
self.zoom_init = (0, 1)
self.zoom_lims = []
self.viewpad = 2.5
self.title = ' '
self.xscale = 'linear'
self.yscale = 'linear'
self.xlabel = ' '
self.ylabel = ' '
self.y2label = ' '
self.added_texts = []
self.plot_type = 'lineplot'
self.scatter_size = 30
self.scatter_normalcolor = 'blue'
self.scatter_normaledge = 'blue'
self.scatter_selectcolor = 'red'
self.scatter_selectedge = 'red'
self.scatter_xdata = None
self.scatter_ydata = None
self.scatter_mask = None
self.margins = None
self.auto_margins = True
self.legend_loc = 'best'
self.legend_onaxis = 'on plot'
self.mpl_legend = None
self.show_grid = True
self.draggable_legend = False
self.hidewith_legend = True
self.show_legend = False
self.show_legend_frame = False
self.axes_style = 'box'
f0 = FontProperties()
self.labelfont = f0.copy()
self.titlefont = f0.copy()
self.legendfont = f0.copy()
self.legendfont.set_size(7)
self.labelfont.set_size(9)
self.titlefont.set_size(10)
self.color_themes = ColorThemes
self.color_theme = 'light'
self.set_color_theme(self.color_theme)
# preload some traces
self.ntrace = 0
self.lines = [None]*200
self.traces = []
self.reset_trace_properties()
示例2: __init__
# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import copy [as 别名]
def __init__(self,Model_suite,**input_parameters):
self.working_directory = '.'
self.station_listfile = None
self.station_xyfile = None
self.Model_suite = Model_suite
self.modeltype = 'model'
self.fig_width = 1.
self.ax_width = 0.03
self.ax_height = 0.8
self.ax_bottom = 0.1
self.plot_spacing = 0.02
self.ylim = [6,0]
self.title_type = 'single'
self.titles = {'minmax':'Minimum and maximum resistivity, $\Omega m$',
'aniso':'Anisotropy in resistivity',# (maximum/minimum resistivity)
'strike':'Strike angle of minimum resistivity'}#, $^\circ$
self.xlim = {'minmax':[0.1,1000],
'aniso':[0,20],
'strike':[0,180]}
self.fonttype = 'serif'
self.label_fontsize = 8
self.title_fontsize = 12
for key in input_parameters.keys():
setattr(self,key,input_parameters[key])
font0 = FontProperties()
font = font0.copy()
font.set_family(self.fonttype)
self.font = font
self.working_directory = os.path.abspath(self.working_directory)
示例3: drawtable
# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import copy [as 别名]
def drawtable(data, rows, columns, title, folder='Table', rowname='',fmt='{:.2f}'):
nrows = len(rows)
ncols = len(columns)
fig, ax = plt.subplots(figsize=(ncols+2,nrows+2))
ax.set_axis_off()
rowlc='#F0F0F0'
collc='#F0F0F0'
cellc='#FFFFFF'
ecol='#0000FF'
font1 = FontProperties()
font1.set_size('9')
fontl = font1.copy()
fontl.set_weight('bold')
tb = Table(ax)#, bbox=[0.10,0.10,0.90,0.90])
tb.auto_set_font_size(False)
#tb.set_fontsize(100.0)
width, height = 0.95/(ncols+1), 0.95/(nrows+1)
for i in range(nrows):
tb.add_cell(i,-1, width*2, height, text=rows[i][:20], loc='right',edgecolor=ecol, facecolor=rowlc,fontproperties=fontl)
# Column Labels
for j in range(ncols):
tb.add_cell(-1, j, width, height/1.5, text=columns[j][:10], loc='center', edgecolor=ecol, facecolor=collc,fontproperties=fontl)
tb.add_cell(-1,-1, width*2, height/1.5, text=rowname[:10], loc='right',edgecolor=ecol, facecolor=rowlc,fontproperties=fontl)
# Add cells
for i in range(len(data)):
for j in range(len(data[i])):
val = data[i][j]
tb.add_cell(i,j,width, height, text=fmt.format(val), loc='center', edgecolor=ecol, facecolor=cellc, fontproperties=font1)
# Row Labels
ax.add_table(tb)
plt.savefig(folder+'/'+title+'.pdf')
#plt.show()
#sys.exit(0)
plt.close()
示例4: createFont
# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import copy [as 别名]
def createFont(family = None, style = None, variant = None, weight = None,
stretch = None, size = None, fontFilePathName = None):
"""Returns a Font Object for text in Matplotlib."""
#### Copy Global Font Properties ####
if fontFilePathName:
try:
font0 = FontProperties(fname = fontFilePathName)
except:
font0 = FontProperties()
else:
font0 = FontProperties()
font = font0.copy()
#### Adjust Based on Arguments ####
if family != None:
font.set_family(family)
if style != None:
font.set_style(style)
if variant != None:
font.set_variant(variant)
if weight != None:
font.set_weight(weight)
if stretch != None:
font.set_stretch(stretch)
if size != None:
font.set_size(size)
return font
示例5: set_defaults
# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import copy [as 别名]
def set_defaults(self):
self.zoom_x = 0
self.zoom_y = 0
self.zoom_init = (0, 1)
self.title = ' '
self.xlabel = ' '
self.ylabel = ' '
self.y2label = ' '
self.plot_type = 'lineplot'
self.cursor_mode = 'zoom'
self.scatter_size = 6
self.scatter_normalcolor = 'blue'
self.scatter_normaledge = 'blue'
self.scatter_selectcolor = 'red'
self.scatter_selectedge = 'red'
self.scatter_data = None
self.scatter_coll = None
self.scatter_mask = None
self.legend_loc = 'upper right'
self.legend_onaxis = 'on plot'
self.mpl_legend = None
self.show_grid = True
self.show_legend = False
self.show_legend_frame = False
# self.trace_color_callback = trace_color_callback
f0 = FontProperties()
self.labelfont = f0.copy()
self.titlefont = f0.copy()
self.labelfont.set_size(9)
self.titlefont.set_size(10)
self.textcolor = '#000000'
self.grid_color = '#E5E5E5'
# preload some traces
self.ntrace = 0
self.lines = [None]*30
self.traces = []
self._init_trace( 0, 'blue', 'solid')
self._init_trace( 1, 'red', 'solid')
self._init_trace( 2, 'black', 'solid')
self._init_trace( 3, 'magenta', 'solid')
self._init_trace( 4, 'green3', 'solid')
self._init_trace( 5, 'maroon', 'solid')
self._init_trace( 6, 'blue', 'dashed')
self._init_trace( 7, 'red', 'dashed')
self._init_trace( 8, 'black', 'dashed')
self._init_trace( 9, 'magenta', 'dashed')
self._init_trace(10, 'green3', 'dashed')
self._init_trace(11, 'maroon', 'dashed')
self._init_trace(12, 'blue', 'dotted')
self._init_trace(13, 'red', 'dotted')
self._init_trace(14, 'black', 'dotted')
self._init_trace(15, 'magenta', 'dotted')
self._init_trace(16, 'green3', 'dotted')
self._init_trace(17, 'maroon', 'dotted')
self._init_trace(18, 'blue', 'solid', marker='+')
self._init_trace(19, 'red', 'solid', marker='+')
self._init_trace(20, 'black', 'solid', marker='o')
示例6: __init__
# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import copy [as 别名]
def __init__(self):
self.axes = None
self.canvas = None
self.fig = None
self.zoom_x = 0
self.zoom_y = 0
self.zoom_init = (0,1)
self.title = ' '
self.xlabel = ' '
self.ylabel = ' '
self.styles = StyleMap.keys()
self.symbols = MarkerMap.keys()
self.legend_locs = ['upper right' , 'upper left', 'upper center',
'lower right', 'lower left', 'lower center',
'center left', 'center right', 'right', 'center']
self.legend_onaxis_choices = ['on plot', 'off plot']
self.legend_loc = 'upper right'
self.legend_onaxis = 'on plot'
self.mpl_legend = None
self.show_grid = True
self.show_legend = False
self.show_legend_frame = True
f0 = FontProperties()
self.labelfont = f0.copy()
self.titlefont = f0.copy()
self.labelfont.set_size(12)
self.titlefont.set_size(14)
self.grid_color = '#E0E0E0'
# preload some traces
# color style linewidth marker markersize
self.ntrace = 0
self.lines = [None]*30
self.traces = []
self._init_trace(20,None, 'black' ,'dotted',2,'o', 8)
self._init_trace( 0,None, 'blue', 'solid', 2,None,8)
self._init_trace( 1,None, 'red', 'solid', 2,None,8)
self._init_trace( 2,None, 'black', 'solid', 2,None,8)
self._init_trace( 3,None, 'magenta', 'solid', 2,None,8)
self._init_trace( 4,None, 'darkgreen','solid', 2,None,8)
self._init_trace( 5,None, 'maroon' ,'solid', 2,None,8)
self._init_trace( 6,None, 'blue', 'dashed',2,None,8)
self._init_trace( 7,None, 'red', 'dashed',2,None,8)
self._init_trace( 8,None, 'black', 'dashed',2,None,8)
self._init_trace( 9,None, 'magenta', 'dashed',2,None,8)
self._init_trace(10,None, 'darkgreen','dashed',2,None,8)
self._init_trace(11,None, 'maroon' ,'dashed',2,None,8)
self._init_trace(12,None, 'blue', 'dotted',2,None,8)
self._init_trace(13,None, 'red', 'dotted',2,None,8)
self._init_trace(14,None, 'black', 'dotted',2,None,8)
self._init_trace(15,None, 'magenta', 'dotted',2,None,8)
self._init_trace(16,None, 'darkgreen','dotted',2,None,8)
self._init_trace(17,None, 'maroon' ,'dotted',2,None,8)
self._init_trace(18,None, 'blue' ,'solid',1,'+',8)
self._init_trace(19,None, 'red' ,'solid',1,'+',8)
示例7: get_font
# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import copy [as 别名]
def get_font(self):
font_properties = FontProperties()
font = font_properties.copy()
font.set_size(str(self.font_point.GetValue()))
font.set_name(str(self.font_family.GetValue()))
font.set_slant(str(self.font_style.GetValue()))
font.set_weight(str(self.font_weight.GetValue()))
return font
示例8: plot_histo
# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import copy [as 别名]
def plot_histo( ydata , fileout , color ):
## Define figure enviroment
fig = plt.figure(1)
rect = fig.patch
rect.set_facecolor('white')
axescolor = '#f6f6f6'
ax = plt.subplot(111,axisbg=axescolor)
## Font setting
font0 = FontProperties()
font1 = font0.copy()
font1.set_size('large')
font = font1.copy()
font.set_family('serif')
rc('text',usetex=True)
## Enable grid
gridLineWidth = 0.2
ax.yaxis.grid(True, linewidth=gridLineWidth, linestyle='-', color='0.05')
## Marker setup
colors = [ 'blue' , 'red' , 'blue','red','green','black','brown','orange','black','violet']
markers = ['^','s','o','d','1','v']
## Ticks
xdensity=100
fig.autofmt_xdate(bottom=0.18)
plt.xticks(fontsize=16)
plt.yticks(fontsize=16)
locs,xlabels = plt.xticks()
#locs = np.arange(xinf,xsup,xdensity)
#plt.xticks(locs, map(lambda x: "%d" % x, locs))
locs,ylabels = plt.yticks()
#plt.yticks(locs, map(lambda x: "%e" % x, locs))
## Set title and axis labeling
plt.xlabel(r'\textbf{Grey value}', fontsize=18,position=(0.5,-0.2))
plt.ylabel( r'\textbf{Counts}' , fontsize=18,position=(0.5,0.5))
plt.suptitle(r'\textbf{HISTOGRAM}', fontsize=16, fontweight='bold',
position=(0.53,0.95))
## Plot histogram
n, bins, patches = plt.hist( ydata , 256 , facecolor=color, edgecolor='none' , alpha=1.0 )
## Save plot and show it
#plt.savefig( fileout , facecolor=fig.get_facecolor() , edgecolor='black' )
plt.savefig( fileout , facecolor=fig.get_facecolor() , #edgecolor='black' ,
format='eps', dpi=1000)
plt.show()
示例9: __init__
# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import copy [as 别名]
def __init__(self,aniso_depth_file,**input_parameters):
self.levels = None
self.n_levels = 10
self.escale = 0.001
self.anisotropy_threshold = [1.,100]
self.cmap = 'jet_r'
self.scaleby = 'resmin'
self.anisotropy_display_factor = 0.75
self.xlim = None
self.ylim = None
self.plot_cbar=True
self.cbar_ax = [0.8,0.1,0.08,0.8]
self.imethod = 'linear'
self.scalebar = True
self.aniso_depth_file = aniso_depth_file
self.aniso_depth_file_dict = dict(header_rows=1,
scale='km')
self.xyzfiles = None
self.xyzfiles_dict = dict(header_rows=1,
scale='km')
self.xyzfile_titles = None
self.additional_xy_data = {}
self.plot_text = {}
self.set_titles = True
self.subplot_layout = 'vertical'
self.wspace = 0.02
self.hspace = 0.15
self.fonttype = 'serif'
self.figsize=(8,5)
for key in input_parameters.keys():
if hasattr(self,str.lower(key)):
setattr(self,key,input_parameters[key])
self.read_aniso_depth_data()
if self.xyzfiles is not None:
if type(self.xyzfiles) == str:
self.xyzfiles = [self.xyzfiles]
if self.xyzfile_titles is None:
titles = []
for f in self.xyzfiles:
titles.append(op.basename(f))
self.xyzfile_titles = titles
else:
if type(self.xyzfile_titles) == str:
self.xyzfile_titles = [self.xyzfile_titles]
while len(self.xyzfile_titles) < len(self.xyzfiles):
self.xyzfile_titles.append('')
font0 = FontProperties()
font = font0.copy()
font.set_family(self.fonttype)
self.font = font
示例10: plot_function
# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import copy [as 别名]
def plot_function( curves , n , args ):
## Common plot settings
if n == 1:
y = curves.copy()
if n == 2:
y = curves[0]
yfit = curves[1]
npix = len( y )
y = y.astype( myfloat )
x = np.arange(npix).astype(myfloat)
fig = plt.figure(1)
rect = fig.patch
rect.set_facecolor('white')
axescolor = '#f6f6f6'
ax = plt.subplot(111,axisbg=axescolor)
font0 = FontProperties()
font1 = font0.copy()
font1.set_size('large')
font = font1.copy()
font.set_family('serif')
rc('text',usetex=True)
gridLineWidth = 0.2
ax.yaxis.grid(True, linewidth=gridLineWidth, linestyle='-', color='0.05')
fig.autofmt_xdate(bottom=0.18)
plt.xticks(fontsize=16)
plt.yticks(fontsize=16)
plt.xlabel(r'\textbf{Pixel index}', fontsize=18,position=(0.5,-0.2))
plt.ylabel( r'\textbf{Grey value}' , fontsize=18,position=(0.5,0.5))
if n == 1:
plt.suptitle(r'\textbf{Input line profile}', fontsize=16, fontweight='bold',
position=(0.53,0.95))
plt.plot( x , y , linewidth=4 , color='b' )
elif n == 2:
plt.suptitle(r'\textbf{Line profile fitted with ERF}', fontsize=16, fontweight='bold',
position=(0.53,0.95))
plt.plot( x , y , 'o' , markersize=6 , color='b' )
plt.hold( True )
plt.plot( x , yfit , linewidth=4 , color='r' )
if n == 2 and args.saveplots is not None:
fileout = args.saveplots
#plt.savefig( fileout , facecolor=fig.get_facecolor() , edgecolor='black' )
plt.savefig( fileout , facecolor=fig.get_facecolor() , #edgecolor='black' ,
format='eps', dpi=1000)
if args.plot is True:
plt.show()
示例11: __init__
# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import copy [as 别名]
def __init__(self, axes=None, fig=None, canvas=None):
self.axes = axes
self.fig = fig
self.canvas = canvas
self.cmap = colormap.gray
self.cmap_reverse = False
self.interp = 'nearest'
self.title = 'map'
self.log_scale = False
self.cmap_lo = 0
self.cmap_hi = self.cmap_range = 100
# self.zoombrush = wx.Brush('#141430', wx.SOLID)
self.zoombrush = wx.Brush('#040410', wx.SOLID)
self.zoompen = wx.Pen('#101090', 3, wx.SOLID)
f0 = FontProperties()
self.titlefont = f0.copy()
self.titlefont.set_size(14)
示例12: add_text
# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import copy [as 别名]
def add_text(self):
"""
Text in the plot
"""
if not self.is_number:
return
self.clear()
try:
self.figure.delaxes(self.figure.axes[0])
self.subplot = self.figure.add_subplot(111)
self.figure.delaxes(self.figure.axes[1])
except:
pass
self.subplot.set_xticks([])
self.subplot.set_yticks([])
label = self.content
FONT = FontProperties()
xpos, ypos = (0.4, 0.5)
font = FONT.copy()
font.set_size(14)
self.textList = []
self.subplot.set_xlim((0, 1))
self.subplot.set_ylim((0, 1))
try:
if self.content != '?':
float(label)
except:
self.subplot.set_frame_on(False)
try:
# mpl >= 1.1.0
self.figure.tight_layout()
except:
self.figure.subplots_adjust(left=0.1, bottom=0.1)
if len(label) > 0 and xpos > 0 and ypos > 0:
new_text = self.subplot.text(str(xpos), str(ypos), str(label),
fontproperties=font)
self.textList.append(new_text)
示例13: onEditLabels
# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import copy [as 别名]
def onEditLabels(self, event):
"""
Edit legend label
"""
try:
selected_plot = self.plots[self.graph.selected_plottable]
except:
selected_plot = self.plots[self.data2D.id]
label = selected_plot.label
dial = TextDialog(None, -1, 'Change Label', label)
if dial.ShowModal() == wx.ID_OK:
try:
FONT = FontProperties()
newlabel = dial.getText()
font = FONT.copy()
font.set_size(dial.getSize())
font.set_family(dial.getFamily())
font.set_style(dial.getStyle())
font.set_weight(dial.getWeight())
colour = dial.getColor()
if len(newlabel) > 0:
# update Label
selected_plot.label = newlabel
self.graph.title(newlabel)
self.title_label = selected_plot.label
self.title_font = font
self.title_color = colour
## render the graph
self.subplot.set_title(label=self.title_label,
fontproperties=self.title_font,
color=self.title_color)
self._is_changed_legend_label = True
self.subplot.figure.canvas.draw_idle()
except:
msg = "Add Text: Error. Check your property values..."
logger.error(msg)
if self.parent is not None:
wx.PostEvent(self.parent, StatusEvent(status=msg))
dial.Destroy()
示例14: plot_location_map
# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import copy [as 别名]
def plot_location_map(self):
"""
plot location map of all stations with profile shown on map.
"""
if self.Model_suite.station_xyfile is None:
print "can't get locations, no x y file"
return
if not hasattr(self,'profile_origin'):
self.get_profile_origin()
font0 = FontProperties()
font = font0.copy()
font.set_family('serif')
xy_all = np.genfromtxt(self.Model_suite.station_xyfile,invalid_raise=False)[:,1:]
plt.plot(xy_all[:,0],xy_all[:,1],'.',c='0.5')
m,c = self.profile
x0,y0 = self.profile_origin
if m > 1:
y1 = max(self.Model_suite.y)
x1 = (y1-c)/m
else:
x1 = max(self.Model_suite.x)
y1 = m*x1 + c
plt.plot([x0,x1],[y0,y1],'k')
plt.plot(self.Model_suite.x,self.Model_suite.y,'k.')
ax=plt.gca()
for label in ax.get_yticklabels():
label.set_fontproperties(font)
for label in ax.get_xticklabels():
label.set_fontproperties(font)
示例15: Basemap
# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import copy [as 别名]
width = 14000000
height = 10000000
# m = Basemap(width=width,height=height,\
# resolution='c',projection='aeqd',\
# lat_0=lat_0,lon_0=lon_0)
# m = Basemap(resolution='c',projection='aeqd',lat_0=lat_0,lon_0=lon_0)
# m = Basemap(width=width,height=height,\
# resolution='c',projection='aea',\
# lat_0=lat_0,lon_0=lon_0)
m = Basemap(resolution="c", projection="mbtfpq", lon_0=lon_0)
# m = Basemap(resolution='c',projection='moll',lon_0=lon_0)
# m = Basemap(resolution='c',projection='ortho',lon_0=lon_0,lat_0=lat_0)
# m = Basemap(resolution='c',projection='cyl',llcrnrlat=llcrnrlat,llcrnrlon=llcrnrlon,urcrnrlat=urcrnrlat,urcrnrlon=urcrnrlon)
p = FontProperties()
font1 = p.copy()
font1.set_size("small")
# draw coasts and fill continents.
m.drawcoastlines(linewidth=0.5)
# m.fillcontinents()
m.drawparallels(arange(-80, 81, 10), labels=[1, 1, 0, 0], fontproperties=font1, labelstyle="+/-")
m.drawmeridians(arange(-180, 180, 20), labels=[0, 0, 0, 1], fontproperties=font1, labelstyle="+/-")
m.drawmapboundary()
m.bluemarble()
m.drawmapboundary()
if arg1 < saa_switch_time:
# Use the previous definitions
# SAA 02