本文整理汇总了Python中matplotlib.pyplot.minorticks_on函数的典型用法代码示例。如果您正苦于以下问题:Python minorticks_on函数的具体用法?Python minorticks_on怎么用?Python minorticks_on使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了minorticks_on函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: apcorr_plot
def apcorr_plot(self):
'''
Creates a plot of delta_mag versus instru_mag to determine in which
region(s) to compute zpt_off.
'''
counts1, counts2, insmag1, insmag2, delta_mag, vegamag = \
self.mag_calc()
for image in self.imlist:
mpl.rcParams['font.family'] = 'Times New Roman'
mpl.rcParams['font.size'] = 12.0
mpl.rcParams['xtick.major.size'] = 10.0
mpl.rcParams['xtick.minor.size'] = 5.0
mpl.rcParams['ytick.major.size'] = 10.0
mpl.rcParams['ytick.minor.size'] = 5.0
mpl.minorticks_on()
mpl.ion()
mpl.title(image)
mpl.ylabel('$\Delta$ mag (r=' + self.apertures[0] + ', ' + \
self.apertures[-1] + ')')
mpl.xlabel('-2.5 log(flux)')
mpl.scatter(insmag1, delta_mag, s=1, c='k')
mpl.savefig(image[:-9] + '_apcorr.png')
left = raw_input('left: ')
right = raw_input('right: ')
bottom = raw_input('bottom: ')
top = raw_input('top: ')
mpl.close()
zpt_off_calc(left, right, top, bottom)
示例2: make_lick_individual
def make_lick_individual(targetSN, w1, w2):
""" Make maps for the kinematics. """
filename = "lick_corr_sn{0}.tsv".format(targetSN)
binimg = pf.getdata("voronoi_sn{0}_w{1}_{2}.fits".format(targetSN, w1, w2))
intens = "collapsed_w{0}_{1}.fits".format(w1, w2)
extent = calc_extent(intens)
bins = np.loadtxt(filename, usecols=(0,), dtype=str).tolist()
bins = np.array([x.split("bin")[1] for x in bins]).astype(int)
data = np.loadtxt(filename, usecols=np.arange(25)+1).T
labels = [r'Hd$_A$', r'Hd$_F$', r'CN$_1$', r'CN$_2$', r'Ca4227', r'G4300',
r'Hg$_A$', r'Hg$_F$', r'Fe4383', r'Ca4455', r'Fe4531', r'C4668',
r'H$_\beta$', r'Fe5015', r'Mg$_1$', r'Mg$_2$', r'Mg$_b$', r'Fe5270',
r'Fe5335', r'Fe5406', r'Fe5709', r'Fe5782', r'Na$_D$', r'TiO$_1$',
r'TiO$_2$']
mag = "[mag]"
ang = "[\AA]"
units = [ang, ang, mag, mag, ang, ang,
ang, ang, ang, ang, ang, ang,
ang, ang, mag, mag, ang, ang,
ang, ang, ang, ang, ang, mag,
mag]
lims = [[None, None], [None, None], [None, None], [None, None],
[None, None], [None, None], [None, None], [None, None],
[None, None], [None, None], [None, None], [None, None],
[None, None], [None, None], [None, None], [None, None],
[None, None], [None, None], [None, None], [None, None],
[None, None], [None, None], [None, None], [None, None],
[None, None], [None, None], [None, None], [None, None]]
pdf = PdfPages("figs/lick_sn{0}.pdf".format(targetSN))
fig = plt.figure(1, figsize=(6.25,5))
plt.subplots_adjust(bottom=0.12, right=0.97, left=0.09, top=0.96)
plt.minorticks_on()
ax = plt.subplot(111)
ax.minorticks_on()
plot_indices = np.arange(12,22)
for i, vector in enumerate(data):
if i not in plot_indices:
continue
print "Making plot for {0}...".format(labels[i])
kmap = np.zeros_like(binimg)
kmap[:] = np.nan
for bin,v in zip(bins, vector):
idx = np.where(binimg == bin)
kmap[idx] = v
vmin = lims[i][0] if lims[i][0] else np.median(vector) - 2 * vector.std()
vmax = lims[i][1] if lims[i][1] else np.median(vector) + 2 * vector.std()
m = plt.imshow(kmap, cmap="inferno", origin="bottom", vmin=vmin,
vmax=vmax, extent=extent, aspect="equal")
make_contours()
plt.minorticks_on()
plt.xlabel("X [kpc]")
plt.ylabel("Y [kpc]")
plt.xlim(extent[0], extent[1])
plt.ylim(extent[2], extent[3])
cbar = plt.colorbar(m)
cbar.set_label("{0} {1}".format(labels[i], units[i]))
pdf.savefig()
plt.clf()
pdf.close()
return
示例3: make_voronoi_intens
def make_voronoi_intens(targetSN, w1, w2):
""" Make image"""
image = "collapsed_w{0}_{1}.fits".format(w1, w2)
intens = pf.getdata(image)
extent = calc_extent(image)
vordata = pf.getdata("voronoi_sn{0}_w{1}_{2}.fits".format(targetSN, w1,
w2))
vordata = np.ma.array(vordata, mask=np.isnan(vordata))
bins = np.unique(vordata)[:-1]
combined = np.zeros_like(intens)
combined[:] = np.nan
for j, bin in enumerate(bins):
idx, idy = np.where(vordata == bin)
flux = intens[idx,idy]
combined[idx,idy] = np.nanmean(flux)
vmax = np.nanmedian(intens) + 4 * np.nanstd(intens)
fig = plt.figure(1)
plt.minorticks_on()
make_contours()
plt.imshow(combined, cmap="cubehelix_r", origin="bottom", vmax=vmax,
extent=extent, vmin=0)
plt.xlabel("X [kpc]")
plt.ylabel("Y [kpc]")
cbar = plt.colorbar()
cbar.set_label("Flux [$10^{-20}$ erg s$^{-1}$ cm$^{-2}$]")
plt.savefig("figs/intens_sn{0}.png".format(targetSN), dpi=300)
pf.writeto("figs/intens_sn{0}.fits".format(targetSN), combined,
clobber=True)
return
示例4: plotshare
def plotshare(self):
datesaxis=mdates.date2num(self.dates)
fig0=plt.figure()
ax0=fig0.add_subplot(1,1,1)
dateFmt = mdates.DateFormatter('%Y-%m-%d')
ax0.xaxis.set_major_formatter(dateFmt)
plt.minorticks_on()
N=len(datesaxis)
#ax0.xaxis.set_major_locator(DaysLoc)
index=np.arange(N)
# dev=np.abs(self.share_prices[:,0]-self.share_prices[:,2])
# p0=plt.errorbar(index,self.share_prices,dev, fmt='.-',ecolor='green',elinewidth=0.1,linewidth=1)
p0=plt.plot(index,self.share_prices)
ax0.legend([p0],[symbol])
ax0.set_ylabel( u'Index')
ax0.xaxis.set_major_formatter(ticker.FuncFormatter(lambda x, pos=None: dates[int(x)]))
ax0.set_xticks(np.arange(0,index[-1],4))
ax0.set_xlim(index[0],index[-1])
fig0.autofmt_xdate(rotation=90)
fig0.savefig('./figures/sharesPrices.eps')
plt.show()
示例5: SetAxes
def SetAxes(legend=False):
f_b = 0.164
f_star = 0.01
err_b = 0.006
err_star = 0.004
f_gas = f_b - f_star
err_gas = np.sqrt(err_b**2 + err_star**2)
plt.axhline(y=f_gas, ls='--', c='k', label='', zorder=-1)
x = np.linspace(.0,2.,1000)
plt.fill_between(x, y1=f_gas - err_gas, y2=f_gas + err_gas, color='k', alpha=0.3, zorder=-1)
plt.text(.6, f_gas+0.006, r'f$_{gas}$', verticalalignment='bottom', size='large')
plt.xlabel(r'r/r$_{vir}$', size='x-large')
plt.ylabel(r'f$_{gas}$ ($<$ r)', size='x-large')
plt.xscale('log')
plt.xticks([1./1.9, 1.33/1.9, 1, 1.5, 2.],[r'r$_{500}$', r'r$_{200}$', 1, 1.5, 2], size='large')
#plt.yticks([.1, .2], ['0.10', '0.20'])
plt.tick_params(length=10, which='major')
plt.tick_params(length=5, which='minor')
plt.xlim([0.4,1.5])
plt.minorticks_on()
if legend:
plt.legend(loc=0, prop={'size':'small'}, markerscale=0.7, numpoints=1, ncol=2)
示例6: plot_hist
def plot_hist(x1,bins=config.cfg.get('hbins',500),name='',label='',tile='',w=None):
print 'hist ',label,tile
if tile!='':
bins/=10
plt.figure()
if (w is None)|(tile!=''):
plt.hist(x1,bins=bins,histtype='stepfilled')
else:
plt.hist(x1,bins=bins,alpha=0.25,normed=True,label='unweighted',histtype='stepfilled')
plt.hist(x1,bins=bins,alpha=0.25,normed=True,weights=w,label='weighted',histtype='stepfilled')
plt.ylabel(r'$n$')
s=config.lbl.get(label,label.replace('_','-'))
if config.log_val.get(label,False):
s='log '+s
plt.xlabel(s+' '+tile)
plt.minorticks_on()
if tile!='':
name='tile_'+tile+'_'+name
plt.legend(loc='upper right',ncol=2, frameon=True,prop={'size':12})
plt.savefig('plots/hist/hist_'+name+'_'+label.replace('_','-')+'.png', bbox_inches='tight')
plt.close()
return
示例7: plotter
def plotter(x, y, image, dep_var, ind_var):
"""
:param x: your dependent variable
:param y: your independent variable
:return:
"""
# todo - make little gridlines
# turn your x and y into numpy arrays
x = np.array(x)
y = np.array(y)
ETrF_vs_NDVI = plt.figure()
aa = ETrF_vs_NDVI.add_subplot(111)
aa.set_title('Bare soils/Tailings Pond - {}'.format(image), fontweight='bold')
aa.set_xlabel('{}'.format(dep_var), style='italic')
aa.set_ylabel('{}'.format(ind_var), style='italic')
aa.scatter(x, y, facecolors='none', edgecolors='blue')
plt.minorticks_on()
# aa.grid(b=True, which='major', color='k')
aa.grid(b=True, which='minor', color='white')
plt.tight_layout()
# TODO - UNCOMMENT AND CHANGE THE PATH TO SAVE THE FIGURE AS A PDF TO A GIVEN LOCATION.
# plt.savefig(
# "/Volumes/SeagateExpansionDrive/jan_metric_PHX_GR/green_river_stack/stack_output/20150728_ETrF_NDVI_gr.pdf")
plt.show()
示例8: plot_results
def plot_results(dists):
for i, d in enumerate(dists):
ax = plt.subplot(3,3,(4*i)+1)
N, bins, patches = plt.hist(d.data, color="b",ec="k", bins=30, \
range=tuple(d.lims), normed=True, \
edgecolor="k", histtype='bar',linewidth=1.)
fracs = N.astype(float)/N.max()
norm = Normalize(-.2* fracs.max(), 1.5 * fracs.max())
for thisfrac, thispatch in zip(fracs, patches):
color = cm.gray_r(norm(thisfrac))
thispatch.set_facecolor(color)
thispatch.set_edgecolor("w")
x = np.linspace(d.data.min(), d.data.max(), 100)
ylim = ax.get_ylim()
plt.plot(x, d.best.pdf(x), "-r", lw=1.5, alpha=0.7)
ax.set_ylim(ylim)
plt.axvline(d.best.MAPP, c="r", ls="--", lw=1.5)
plt.tick_params(labelright=True, labelleft=False, labelsize=10)
plt.xlim(d.lims)
plt.locator_params(axis='x',nbins=10)
if i < 2:
plt.setp(ax.get_xticklabels(), visible=False)
else:
plt.xlabel(r"[$\mathregular{\alpha}$ / Fe]")
plt.minorticks_on()
def hist2D(dist1, dist2):
""" Plot distribution and confidence contours. """
X, Y = np.mgrid[dist1.lims[0] : dist1.lims[1] : 20j,
dist2.lims[0] : dist2.lims[1] : 20j]
extent = [dist1.lims[0], dist1.lims[1], dist2.lims[0], dist2.lims[1]]
positions = np.vstack([X.ravel(), Y.ravel()])
values = np.vstack([dist1.data, dist2.data])
kernel = stats.gaussian_kde(values)
Z = np.reshape(kernel(positions).T, X.shape)
ax.imshow(np.rot90(Z), cmap="gray_r", extent=extent, aspect="auto",
interpolation="spline16")
plt.axvline(dist1.best.MAPP, c="r", ls="--", lw=1.5)
plt.axhline(dist2.best.MAPP, c="r", ls="--", lw=1.5)
plt.tick_params(labelsize=10)
ax.minorticks_on()
plt.locator_params(axis='x',nbins=10)
return
ax = plt.subplot(3,3,4)
hist2D(dists[0], dists[1])
plt.setp(ax.get_xticklabels(), visible=False)
plt.ylabel("[Z/H]")
plt.xlim(dists[0].lims)
plt.ylim(dists[1].lims)
ax = plt.subplot(3,3,7)
hist2D(dists[0], dists[2])
plt.ylabel(r"[$\mathregular{\alpha}$ / Fe]")
plt.xlabel("log Age (yr)")
plt.xlim(dists[0].lims)
plt.ylim(dists[2].lims)
ax = plt.subplot(3,3,8)
plt.xlabel("[Z/H]")
hist2D(dists[1], dists[2])
plt.xlim(dists[1].lims)
plt.ylim(dists[2].lims)
return
示例9: plot_density
def plot_density(x, primary=True):
"""
Creates a density plot of the data.
Code is based on this forum message http://stackoverflow.com/a/4152016
:param x: (array like)
the data
"""
# Calculate the density points
density = gaussian_kde(x)
# TODO: COme up with a better start and end point
xs = linspace(min(x)-1, max(x)+1, 200)
density.covariance_factor = lambda : 0.25
density._compute_covariance()
plt.plot(xs,density(xs), color='#0066FF', alpha=0.7)
# Add Grid lines
plt.minorticks_on()
plt.grid(b=True, which='major', color='#666666', linestyle='-')
plt.grid(b=True, which='minor', color='#999999', linestyle='-', alpha=0.2)
# Render the plot
if primary:
plt.show()
示例10: save
def save(self):
result = self.bands.all()
# indexes are negative because they
# represent the number of days in the past
index = [ (i.get("index")+1)*-1 for i in result ]
close = [ i.get("close") for i in result ]
up = [ i.get("up") for i in result ]
middle = [ i.get("middle") for i in result ]
down = [ i.get("down") for i in result ]
plt.plot(index, up, label="upper band")
plt.plot(index, down, label="lower band")
plt.plot(index, middle, label="middle band")
plt.plot(index, close, label="close price")
plt.xlabel("Past days (0 = today)")
plt.ylabel("Value (USD$)")
plt.title("%s bollinger bands" % (self.bands.symbol))
# enables the grid for every single decimal value
plt.minorticks_on()
plt.grid(True, which="both")
legend = plt.legend(fancybox=True, loc="best")
legend.get_frame().set_alpha(0.5)
plt.savefig(self.bands.symbol+".png")
# the plot must be closed for otherwhise matplotlib
# will paint over previous plots
plt.close()
示例11: disp_frame
def disp_frame(x_data, y_data, mag_data):
'''
Show full frame.
'''
coord, x_name, y_name = prep_plots.coord_syst()
st_sizes_arr = prep_plots.star_size(mag_data)
plt.gca().set_aspect('equal')
# Get max and min values in x,y
x_min, x_max = min(x_data), max(x_data)
y_min, y_max = min(y_data), max(y_data)
# Set plot limits
plt.xlim(x_min, x_max)
plt.ylim(y_min, y_max)
# If RA is used, invert axis.
if coord == 'deg':
plt.gca().invert_xaxis()
# Set axis labels
plt.xlabel('{} ({})'.format(x_name, coord), fontsize=12)
plt.ylabel('{} ({})'.format(y_name, coord), fontsize=12)
# Set minor ticks
plt.minorticks_on()
# Set grid
plt.grid(b=True, which='major', color='k', linestyle='-', zorder=1)
plt.grid(b=True, which='minor', color='k', linestyle='-', zorder=1)
plt.scatter(x_data, y_data, marker='o', c='black', s=st_sizes_arr)
plt.draw()
print 'Plot displayed, waiting for it to be closed.'
示例12: plot_v_of_t
def plot_v_of_t(volume_list,name,iteration):
"""Plots 2-volume as a function of proper time. Takes the output of
make_v_of_t.
name = name of simulation
iteration = number of spacetime in ensemble. Might be sweep# instead."""
# Defines the plot
vplot = plt.plot(volume_list, 'bo', volume_list, 'r-')
# plot title is made of name+iteration
plot_title = name+' '+str(iteration)
# Labels and Titles
plt.title(plot_title)
plt.xlabel('Proper Time')
plt.ylabel('2-Volume Per Time Slice')
# Ensure the y range is appropriate
plt.ylim([np.min(volume_list)-.5,np.max(volume_list)+.5])
# Turn on minor ticks
plt.minorticks_on()
# Show the plot
plt.show()
return
示例13: __init__
def __init__(self, parent):
# super(StocksGraphView, self).__init__(parent)
self.fatherHandle = parent
self.figure = plt.gcf()
self.ax = self.figure.gca()
self.canvas = figureCanvas(self.figure)
self.hintText = self.ax.text(-.5, -.5, "", ha="right", va="baseline", fontdict={"size": 15})
self.figure.canvas.mpl_connect('key_press_event', self._on_key_press)
self.figure.canvas.mpl_connect('button_press_event', self._on_button_press)
# figure.canvas.mpl_disconnect(figure.canvas.manager.key_press_handler_id)
self.figure.canvas.mpl_connect('motion_notify_event', self._on_mouse_move)
self._lines = {}
self._hHintLine = None
self._vHintLine = None
self.ax.fmt_date = matplotlib.dates.DateFormatter('%Y-%m-%d')
self.strpdate2num = matplotlib.dates.strpdate2num('%Y-%m-%d')
plt.subplots_adjust(left=.04, bottom=.0, right=.98, top=.97,
wspace=.0, hspace=.0)
plt.minorticks_on()
self.ax.grid()
self.ax.xaxis.set_major_formatter(matplotlib.dates.DateFormatter('%y\n-\n%m\n-\n%d'))
示例14: SetAxes
def SetAxes(legend=False):
# plt.axhline(y=0.165, ls='-', c='k', label=r'$\Omega_{b}$/$\Omega_{M}$ (WMAP)')
f_b = 0.164
f_star = 0.01
err_b = 0.004
err_star = 0.004
f_gas = f_b - f_star
err_gas = np.sqrt(err_b**2 + err_star**2)
plt.axhline(y=f_gas, ls='--', c='k', label='', zorder=-1)
x = np.linspace(1e+13,200e+13,1000)
plt.fill_between(x, y1=f_gas - err_gas, y2=f_gas + err_gas, color='k', alpha=0.3, zorder=-1)
plt.text(10e+13, f_gas+0.005, r'f$_{gas}$', verticalalignment='bottom', size='large')
plt.xlabel(r'M$_{vir}$ (M$_\odot$)', size='x-large')
plt.ylabel(r'f$_{gas}$ ($<$ r)', size='x-large')
plt.xscale('log')
plt.xlim([1e+13,2e+15])
plt.ylim(ymin=0.03)
plt.tick_params(length=10, which='major')
plt.tick_params(length=5, which='minor')
plt.minorticks_on()
if legend:
plt.legend(loc=0, prop={'size':'large'}, markerscale=0.7, numpoints=1)
示例15: prettyplot
def prettyplot():
ticks_font = font_manager.FontProperties(family='Helvetica', style='normal',
size=16, weight='normal', stretch='normal')
font = {'family': 'Helvetica', 'size': 10}
matplotlib.rc('font',**font)
#matplotlib.rc('ylabel',fontweight='bold',fontsize=18,labelpad=20)
matplotlib.rcParams['axes.labelsize'] = 18
matplotlib.rcParams['axes.labelweight'] = 'bold'
matplotlib.rcParams['axes.titlesize'] = 20
#matplotlib.rcParams['axes.titleweight'] = 'bold'
plt.figure()
ax = plt.axes()
for label in ax.get_xticklabels():
#print label.get_text()
label.set_fontproperties(ticks_font)
for label in ax.get_yticklabels():
label.set_fontproperties(ticks_font)
plt.minorticks_on()
plt.tick_params(axis='both', which='major', labelsize=12)
plt.gcf().subplots_adjust(bottom=0.15)
plt.gcf().subplots_adjust(left=0.15)
t = plt.title('')
t.set_y(1.05)
t.set_fontweight('bold')
x = ax.set_xlabel('',labelpad=20)
y = ax.set_ylabel('',labelpad=20)