• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python pyplot.axhline函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中matplotlib.pyplot.axhline函数的典型用法代码示例。如果您正苦于以下问题:Python axhline函数的具体用法?Python axhline怎么用?Python axhline使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了axhline函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: display_convw2

def display_convw2(w, s, r, c, fig, title='conv_filters'):
  """w: num_filters X sizeX**2 * num_colors."""
  num_f, num_d = w.shape
  assert s**2 * 3 == num_d
  pvh = np.zeros((s*r, s*c, 3))
  for i in range(r):
    for j in range(c):
      pvh[i*s:(i+1)*s, j*s:(j+1)*s, :] = w[i*c + j, :].reshape(3, s, s).T
  mx = pvh.max()
  mn = pvh.min()
  pvh = 255*(pvh - mn) / (mx-mn)
  pvh = pvh.astype('uint8')
  plt.figure(fig)
  plt.suptitle(title)
  plt.imshow(pvh, interpolation="nearest")
  scale = 1
  xmax = s * c
  ymax = s * r
  color = 'k'
  for x in range(0, c):
    plt.axvline(x=x*s/scale, ymin=0, ymax=ymax/scale, color=color)
  for y in range(0, r):
    plt.axhline(y=y*s/scale, xmin=0, xmax=xmax/scale, color=color)
  plt.draw()
  return pvh
开发者ID:tbluche,项目名称:deepnet,代码行数:25,代码来源:visualize.py


示例2: plotresult

def plotresult(i=0, j=101, step=1):
    import matplotlib.pyplot as mpl
    from numpy import arange

    res = getevaluation(i, j, step)
    x = [k / 100.0 for k in range(i, j, step)]
    nbcurve = len(res[0])
    nres = [[] for i in xrange(nbcurve)]
    mres = []
    maxofmin = -1, 0.01
    for kindex, kres in enumerate(res):
        minv = min(kres.values())
        if minv > maxofmin[1]:
            maxofmin = kindex, minv
        lres = [(i, j) for i, j in kres.items()]
        lres.sort(lambda x, y: cmp(x[0], y[0]))
        for i, v in enumerate(lres):
            nres[i].append(v[1])
        mres.append(sum([j for i, j in lres]) / nbcurve)
    print maxofmin
    for y in nres:
        mpl.plot(x, y)
    mpl.plot(x, mres, linewidth=2)
    mpl.ylim(0.5, 1)
    mpl.xlim(0, 1)
    mpl.axhline(0.8)
    mpl.axvline(0.77)
    mpl.xticks(arange(0, 1.1, 0.1))
    mpl.yticks(arange(0.5, 1.04, 0.05))
    mpl.show()
开发者ID:openalea,项目名称:lpy,代码行数:30,代码来源:evalrange.py


示例3: main

def main( args ):

  hash = get_genes_with_features(args['file'])
  for key, featurearray in hash.iteritems():
    cluster, branch = key.split()
    length = int(featurearray[0][0])
    import matplotlib.pyplot as P
    x = [e+1 for e in range(length+1)]
    y1 = [0] * (length+1)
    y2 = [0] * (length+1)
    for feature in featurearray:
      length, pos, aa, prob = feature[0:4]
      if prob > 0.95: y1[pos] = prob
      else: y2[pos] = prob
    
    P.bar(x, y1, color='#000000', edgecolor='#000000')
    P.bar(x, y2, color='#bbbbbb', edgecolor='#bbbbbb')
    P.ylim(ymin=0, ymax=1)
    P.xlim(xmin=0, xmax=length)
    P.xlabel("position in the ungapped alignment [aa]")
    P.ylabel(r'$P (\omega > 1)$')
    P.title(cluster + " (branch " + branch + ")")

    P.axhline(y=.95, xmin=0, xmax=length, linestyle=":", color="k")
    P.savefig(cluster + "." + branch + ".png", format="png")
    P.close()
开发者ID:lierhan,项目名称:bioinformatics,代码行数:26,代码来源:plot-codeml-model-A-digest.py


示例4: plot_1d

def plot_1d(xdata, ydata, color, x_axis, y_axis, system, analysis, average = False, t0 = 0, **kwargs):
	""" Creates a 1D scatter/line plot:

	Usage: plot_1d(xdata, ydata, color, x_axis, y_axis, system, analysis, average = [False|True], t0 = 0)
	
	Arguments:
	xdata, ydata: self-explanatory
	color: color to be used to plot data
	x_axis, y_axis: strings to be used for the axis label
	system: descriptor for the system that produced the data
	analysis: descriptor for the analysis that produced the data
	average: [False|True]; Default is False; if set to True, the function will calc the average, standard dev, and standard dev of mean of the y-data	# THERE IS A BUG IF average=True; must read in yunits for this function to work at the moment.
	t0: index to begin averaging from; Default is 0
	
	kwargs:
		xunits, yunits: string with correct math text describing the units for the x/y data
		x_lim, y_lim: list w/ two elements, setting the limits of the x/y ranges of plot
		plt_title: string to be added as the plot title
		draw_line: int value that determines the line style to be drawn; giving myself space to add more line styles if I decide I need them

	"""
	# INITIATING THE PLOT...
	plt.plot(xdata, ydata, '%s' %(color))

	# READING IN KWARG DICTIONARY INTO SPECIFIC VARIABLES
	for name, value in kwargs.items():
		if name == 'xunits':
			x_units = value
			x_axis = '%s (%s)' %(x_axis, value)
		elif name == 'yunits':
			y_units = value
			y_axis = '%s (%s)' %(y_axis, value)
		elif name == 'x_lim':
			plt.xlim(value)
		elif name == 'y_lim':
			plt.ylim(value)
		elif name == 'plt_title':
			plt.title(r'%s' %(value), size='14')
		elif name == 'draw_line':
			draw_line = value
			if draw_line == 1:
				plt.plot([0,max(ydata)],[0,max(ydata)],'r-',linewidth=2)
			else:
				print 'draw_line = %s has not been defined in plotting_functions script' %(line_value)
	
	plt.grid(b=True, which='major', axis='both', color='#808080', linestyle='--')
	plt.xlabel(r'%s' %(x_axis), size=12)
	plt.ylabel(r'%s' %(y_axis), size=12)

	# CALCULATING THE AVERAGE/SD/SDOM OF THE Y-DATA
	if average != False:
		avg = np.sum(ydata[t0:])/len(ydata[t0:])
		SD = stdev(ydata[t0:])
		SDOM = SD/sqrt(len(ydata[t0:]))

		plt.axhline(avg, xmin=0.0, xmax=1.0, c='r')
		plt.figtext(0.680, 0.780, '%s\n%6.4f $\\pm$ %6.4f %s \nSD = %4.3f %s' %(analysis, avg, SDOM, y_units, SD, y_units), bbox=dict(boxstyle='square', ec='r', fc='w'), fontsize=12)

	plt.savefig('%s.%s.plot1d.png' %(system,analysis),dpi=300)
	plt.close()
开发者ID:rbdavid,项目名称:Distance_matrix,代码行数:60,代码来源:plotting_functions.py


示例5: plot_profile

def plot_profile(frame, index):
    T = sc[:,'w_xy'].keys()[frame]
    data = sc[T,'w_xy'][index,:]
    x = sc[0.0,'z_z'][-sc[T,'w_xy'].shape[0]:]

    plt.imshow(sc[T,'w_xy'])
    plt.axhline(index, color='k')
    plt.figure()
    plt.plot(x,data[:])
    plt.xlabel("y")
    plt.ylabel("w")
    plt.figure()
    scalex = np.sqrt(np.abs(data[1]/x[1]) * p['viscosity']) / p['viscosity']
    scaley = 1./np.sqrt(np.abs(data[1]/x[1]) * p['viscosity']) 
    plt.plot(scalex*x[:50],scaley*data[:50], 'x-')
    plt.grid(True)
    plt.xlabel("y+")
    plt.ylabel("w+")
    plt.figure()
    scalex = np.sqrt(np.abs(data[-1]/(x[-1]-1)) * p['viscosity']) / p['viscosity']
    scaley = 1./np.sqrt(np.abs(data[-1]/(x[-1]-1)) * p['viscosity']) 
    plt.plot(scalex*(x[-50:]-1),scaley*data[-50:], 'x-')
    plt.grid(True)
    plt.xlabel("y+")
    plt.ylabel("w+")
开发者ID:maxhutch,项目名称:thesis-notebooks,代码行数:25,代码来源:WJ_validate.py


示例6: getMonthlyReturns

 def getMonthlyReturns(self, lotSizeInUSD,  commissionPerPip):
     prevMonth = 0
     profit = 0
     deals = 0
     monthlyReturns = []
     for p in self.getClosedPositions():
         if prevMonth == 0:
             prevMonth = p.openTime.month
         profit += (p.closePrice - p.order.price) * p.order.orderType * lotSizeInUSD - commissionPerPip
         deals += 1
         if p.openTime.month != prevMonth:
             monthlyReturns.append([profit, deals])
             prevMonth = p.openTime.month
             profit = 0
             deals = 0
     result = np.array(monthlyReturns)
     import matplotlib.pyplot as plt
     plt.figure(1)
     plt.subplot(211)
     plt.axhline(y=0)
     plt.plot(result[:,0])
     plt.subplot(212)
     plt.axhline(y=0)
     plt.plot(result[:,1])
     plt.show()
     return result
开发者ID:forregg,项目名称:cbTester,代码行数:26,代码来源:tester.py


示例7: test_blc2

def test_blc2(oversample=2, verbose=True, wavelength=2e-6, angle=0, kind='circular', sigma=1.0, loc = 0.3998):
    import scipy
    x = np.linspace(-5, 5, 401)
    sigmar = sigma*x
    if kind == 'circular':
        trans = (1-  (2*scipy.special.jn(1,sigmar)/sigmar)**2)**2
    else: 
        trans = (1-  (np.sin(sigmar)/sigmar)**2)**2
    plt.clf()
    plt.plot(x, trans)
    plt.axhline(0.5, ls='--', color='k')


    plt.axvline(loc, ls='--', color='k')
    #plt.gca().set_xbound(loc*0.98, loc*1.02)
    wg = np.where(sigmar > 0.01)
    intfn = scipy.interpolate.interp1d(x[wg], trans[wg])
    print "Value at %.4f :\t%.4f" % (loc, intfn(loc))

    # figure out the FWHM
    #   cut out the portion of the curve from the origin to the first positive maximum
    wp = np.where(x > 0)
    xp = x[wp]
    transp = trans[wp]
    wm = np.argmax(transp)
    wg = np.where(( x>0 )& ( x<xp[wm]))
    interp = scipy.interpolate.interp1d(trans[wg], x[wg])
    print "For sigma = %.4f, HWHM occurs at %.4f" % (sigma, interp(0.5))
开发者ID:astrocaribe,项目名称:webbpsf,代码行数:28,代码来源:test_poppy.py


示例8: wfplot2

def wfplot2(wflist,bounds):
    # improved ploting, it can plot more than one wavefunction, also it can change the plot range, 
    # if the bounds parameter is -1 it plots the wavefunctions in their full range. It also shows the axis x line.

    # usage: wfplot2([ynL],[0,10]) (NOTE THE BRAKETS) to plot ynL in the interval (0,10) or wfplot2([ynL],-1) to plot ynL in its full range, or 
    # wfplot2([ynL,ynL2],-1) to plot two functions in te full range.

    if bounds == -1:
        plt.axhline(0,color='black')
        for element in wflist:
            wfplot(element)
        return plt.show()
                
    elif len(bounds) == 2:
        plt.axhline(0,color='black')
        for element in wflist:
            xmin = min(simm(bounds[0],element[:,0]))
            xmax = max(simm(bounds[1],element[:,0]))
            xaux = element[:,0][xmin:xmax]
            yaux = element[:,1][xmin:xmax]
            plt.plot(np.array(xaux),np.array(yaux)) 
        return plt.show()

    else:
        print 'invalid bounds'
开发者ID:heedmane,项目名称:schroepy,代码行数:25,代码来源:SChroe.py


示例9: _sp

def _sp(data):
    """
    Generate plots of convergence criteria, and energy vs. optimization cycles

    :job: ccdata object, or file
    :returns: TODO

    """
    # TODO scfenergies, scfvalues, scftargets vs. scf cycles
    print("\n\n")
    #print("Optimization Converged: ", data.optdone)
    criteria = [0, 0, 0]
    criteria[0] = [x[0] for x in data.scfvalues]
    criteria[1] = [x[1] for x in data.scfvalues]
    criteria[2] = [x[2] for x in data.scfvalues]
    idx = np.arange(len(criteria[0]))

    # Plot Geometry Optimization Criteria for Convergence over opt cycles
    plt.plot(idx, criteria[0], label='Criteria 1')
    plt.plot(idx, criteria[1], label='Criteria 2')
    plt.plot(idx, criteria[2], label='Criteria 3')

    # Plot target criteria for convergence
    plt.axhline(y=data.scftargets[0])
    plt.yscale('log')

    plt.title("SCF Convergence Analysis")
    plt.xlabel("SCF Cycle")
    plt.legend()

    print(idx, criteria, data.scftargets)

    plt.show()
开发者ID:ben-albrecht,项目名称:qcl,代码行数:33,代码来源:figs.py


示例10: analyze_edge_velocities

def analyze_edge_velocities(df):
    from numpy import arange
    import article2_time_averaged_routines as tar
    import pandas as pd
    import matplotlib.pyplot as plt
    reload(tar)

    # This function was once used to evaluate the selection of 
    # U_e based on different parameters

    conditions = [
        'vorticity_integration_rate_of_change',
        #'u_rms_rate_of_change',
        #'v_rms_rate_of_change',
        #'u_rate_of_change',
    ]

    thresholds = arange(1,100,0.1)[::-1]

    U_e_df = pd.DataFrame()
    for c in conditions:
        U_e = []
        for t in thresholds:
            U_e.append(tar.get_edge_velocity(df, condition = c, threshold = t))
        U_e_df[c] = U_e

    U_e_df.plot()
    plt.axhline( df.u.max() )
    plt.show()

    return U_e_df
开发者ID:carlosarceleon,项目名称:article2_time_averaged,代码行数:31,代码来源:run_article2_analysis.py


示例11: plot_adsorbed_circles

def plot_adsorbed_circles(adsorbed_x, adsorbed_y, radius, width, reference_indices=[]):
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib.patches import Circle

    # Plot each run
    fig = plt.figure()
    ax = fig.add_subplot(111)
    for p in range(len(adsorbed_x)):
        if len(np.where(reference_indices == p)[0]) > 0:
            ax.add_patch(Circle((adsorbed_x[p], adsorbed_y[p]), radius, 
                edgecolor='black', facecolor='black'))
        else:
            ax.add_patch(Circle((adsorbed_x[p], adsorbed_y[p]), radius,
                edgecolor='black', facecolor='white'))

    ax.set_aspect(1.0)
    plt.axhline(y=0, color='k')
    plt.axhline(y=width, color='k')
    plt.axvline(x=0, color='k')
    plt.axvline(x=width, color='k')
    plt.axis([-0.1*width, width*1.1, -0.1*width, width*1.1])
    plt.xlabel("non-dimensional x")
    plt.ylabel("non-dimensional y")

    return ax
开发者ID:lhogstrom,项目名称:BlackAndBlue,代码行数:26,代码来源:rdf_utilities.py


示例12: _double_hit_check

    def _double_hit_check(x):
        # first PSD
        W, fr = PSD(x, dt=dt)
        # second PSD: look for oscillations in PSD
        W2, fr2 = PSD(W, dt=fr[1])
        upto = int(0.01 * len(x))
        max_impact = np.max(W2[:upto])
        max_after_impact = np.max(W2[upto:])
        if plot_figure:
            import matplotlib.pyplot as plt
            plt.subplot(121)
            l = int(0.002*len(x))
            plt.plot(1000*dt*np.arange(l),  x[:l])
            plt.xlabel('t [ms]')
            plt.ylabel('F [N]')
            plt.subplot(122)
            plt.semilogy((W2/np.max(W2))[:5*upto])
            plt.axhline(limit, color='r')
            plt.axvline(upto, color='g')
            plt.xlabel('Double freq')
            plt.ylabel('')
            plt.show()

        if max_after_impact / max_impact > limit:
            return True
        else:
            return False
开发者ID:openmodal,项目名称:openmodal,代码行数:27,代码来源:meas_check.py


示例13: adjust_axes

def adjust_axes(ax, title, header_ticks, header_list, axis_num, cols, axesfontsize):
    '''
    A small helper function that adjusts the axes on the plots
    '''
    
    frame = plt.gca()
    
    axes_font = {'fontsize':axesfontsize}
    title_font = {'fontsize':18}
    
    plt.text(0.1,3, title, **title_font)
    
    plt.axhline()
    
    if (axis_num <= cols) and (axis_num % 2 == 0):
        frame.xaxis.set_ticks_position('top')
        frame.xaxis.set_label_position('top')
        frame.xaxis.tick_top()
        ax.set_xticks(header_ticks)
        ax.set_xticklabels(header_list, **axes_font)
    else:
        frame.axes.get_xaxis().set_visible(False)
        
    if (((axis_num - 1) / cols) % 2 == 0) and axis_num % cols == 1:
        ax.set_yticks((-4,-2,0,2,4))
        ax.set_yticklabels([-4,-2,0,2,4], **axes_font)
    else:
        frame.axes.get_yaxis().set_visible(False)
开发者ID:arubenstein,项目名称:deep_seq,代码行数:28,代码来源:enrich_plot.py


示例14: display_w

def display_w(w, s, r, c, fig, vmax=None, vmin=None, dataset='mnist', title='weights'):

  if dataset == 'norb':
    numvis = 4096
  else:
    numvis = w.shape[0]
  numhid = w.shape[1]
  sc = s
  sr = numvis/s
  if isinstance(w, np.ndarray):
    vh = w.T[:,:sr*sc].reshape(sr*numhid, sc)
  else:
    vh = w.asarray().T[:,:sr*sc].reshape(sr*numhid, sc)
  pvh = np.zeros((sr*r, sc*c))
  for i in range(r):
    for j in range(c):
      pvh[i*sr:(i+1)*sr , j*sc:(j+1)*sc] = vh[ (i*c+j)*sr : (i*c+j+1)*sr ,:]
  plt.figure(fig)
  plt.clf()
  plt.title(title)
  plt.imshow(pvh, cmap = plt.cm.gray, interpolation = 'nearest', vmax=vmax, vmin=vmin)
  scale = 1
  xmax = sc*c
  ymax = sr*r
  color = 'k'
  if r > 1:
    for x in range(0,c):
      plt.axvline(x=x*sc/scale, ymin=0,ymax=ymax/scale, color = color)
  if c > 1:
    for y in range(0,r):
      plt.axhline(y=y*sr/scale, xmin=0,xmax=xmax/scale, color = color)
  plt.draw()

  return pvh
开发者ID:tbluche,项目名称:deepnet,代码行数:34,代码来源:visualize.py


示例15: hpd_beta

def hpd_beta(y, n, h=.1, a=1, b=1, plot=False, **plot_kwds):
    apost = y + a
    bpost = n - y + b
    if apost > 1 and bpost > 1:
        mode = (apost - 1)/(apost + bpost - 2)
    else:
        raise Exception("mode at 0 or 1: HPD not implemented yet")

    post = stats.beta(apost, bpost)

    dmode = post.pdf(mode)

    lt = opt.bisect(lambda x: post.pdf(x) / dmode - h, 0, mode)
    ut = opt.bisect(lambda x: post.pdf(x) / dmode - h, mode, 1)

    coverage = post.cdf(ut) - post.cdf(lt)
    if plot:
        plt.figure()
        plotf(post.pdf)
        plt.axhline(h*dmode)
        plt.plot([ut, ut], [0, post.pdf(ut)])
        plt.plot([lt, lt], [0, post.pdf(lt)])
        plt.title(r'$p(%s < \theta < %s | y)$' %
                  tuple(np.around([lt, ut], 2)))

    return lt, ut, coverage, h
开发者ID:wesm,项目名称:statlib,代码行数:26,代码来源:tools.py


示例16: plot_scatter

def plot_scatter(points, rects, level_id, fig_area=FIG_AREA, grid_area=GRID_AREA, with_axis=False, with_img=True, img_alpha=1.0):
    rect = rects[level_id]
    top_lat, top_lng, bot_lat, bot_lng = get_rect_bounds(rect)

    plevel = get_points_level(points, rects, level_id)
    ax = plevel.plot('lng', 'lat', 'scatter')
    plt.xlim(left=top_lng, right=bot_lng)
    plt.ylim(top=top_lat, bottom=bot_lat)

    if with_img:
        img = plt.imread('/data/images/level%s.png' % level_id)
        plt.imshow(img, zorder=0, alpha=img_alpha, extent=[top_lng, bot_lng, bot_lat, top_lat])

    width, height = get_rect_width_height(rect)
    fig_width, fig_height = get_fig_width_height(width, height, fig_area)
    plt.gcf().set_size_inches(fig_width, fig_height)

    if grid_area:
        grid_horiz, grid_vertic = get_grids(rects, level_id, grid_area, fig_area)
        for lat in grid_horiz:
            plt.axhline(lat, color=COLOR_GRID, lw=GRID_LW)
        for lng in grid_vertic:
            plt.axvline(lng, color=COLOR_GRID, lw=GRID_LW)

    if not with_axis:
        ax.set_axis_off()
        ax.get_xaxis().set_visible(False)
        ax.get_yaxis().set_visible(False)

    return ax
开发者ID:tentangdata,项目名称:pinisi,代码行数:30,代码来源:functions.py


示例17: plot

def plot(data):
	plt.scatter(*zip(*data))
	#plt.ylim(-5,5)
	plt.axhline(0.1)
	plt.xlabel("embedding demension m")
	plt.ylabel("the ratio false neighbors")
	plt.show()
开发者ID:kansuke231,项目名称:ChaoticDynamics,代码行数:7,代码来源:out_plot.py


示例18: TCP_plot

def TCP_plot(no_ind_plots, label):
    #no_ind_plots = 50

    ## individual plots cannot be more than total patients
    if(no_ind_plots>n):
        no_ind_plots=n

    ## want to select the individual plots randomly from those calcualted...
    ind_plots = np.random.choice(len(TCPs),no_ind_plots, replace=False)

    ## individuals (specified number of plots chosen)
    for i in ind_plots:
        plt.plot(nom_doses,TCPs[i], color = 'grey', alpha = 0.5)
    ## population
    plt.plot(nom_doses,TCP_pop, color='black', linewidth='2', alpha=0.5)
    plt.plot(nom_doses,TCP_pop, marker = 'o', ls='none', label=label)

    ## plot formatting
    plt.xlim(0,max(nom_doses))
    plt.ylim(0,1.0)
    plt.xlabel('Dose (Gy)')
    plt.ylabel('TCP')
    plt.title('TCPs')
    #plt.legend(loc = 'best', fontsize = 'medium', framealpha = 1)
    plt.axvline(d_interest, color = 'black', ls='--',)
    plt.axhline(TCP_pop[frac_interest-1], color='black', ls='--')

    ## add labels with TCP at dose of interest
    text_string = ('Pop. TCP = ' + str(round(TCP_cure_at_d_interest,2)) + ' % at ' + str(d_interest) + 'Gy')
    plt.text(5,0.4,text_string, backgroundcolor='white')
    plt.legend(loc = 'lower left',numpoints=1)

    plt.show()
开发者ID:mbolt01,项目名称:InitialCode,代码行数:33,代码来源:TCP-updated-multiple-parameter-variations-Re-order-AddOPTrend.py


示例19: graphAny

def graphAny(df, y):
    yName = np.where(df['Parameter Code'] == y)[0]                                                                      #finds where the param code is in MasterFile06
    yNamedf = df[(yName[0]):(yName[-1]+1)]                                                                              #creates separate DF from MasterFile06 w/ only param
    print(yNamedf['Date'][:1])                                                                                          #prints first date in yNamedf
    print(yNamedf['Date'][-1:])                                                                                         #prints last date in yNamedf
    print(yNamedf['Parameter Description'][:1])                                                                         #prints parameter description
    yNamedf.plot(x='Date', y='Values', kind='line', color='red')                                                        #plotting the new parameter DF
    plt.xlabel('Date')
    yax = input('Enter y-axis label: ')                                                                                 #input whatever you want for y-axis label
    plt.ylabel(yax)                                                                                                     #whatever the input is is what y-axis label is
    #plt.ylabel(yNamedf['Parameter Description'][:1])
    gTitle = input('Enter title: ')                                                                                     #similar to y-axis label...
    plt.title(gTitle)                                                                                                   #whatever the input is is what title is
    referenceLine = input('Does this graph need a reference line? ')
    while referenceLine != 'no':                                                                                        #while statement loops if user doesn't enter 'no'
        yRefL = float(input('Enter y value for reference line: '))                                                      #input whatever number you want ref line to be
        labelRefl = input('Enter reference line description: ')                                                         #input description of line color
        lineColor = input('Enter color for reference line: ')                                                           #input color of reference line
        plt.axhline(y=yRefL, xmin=0, xmax=1, linewidth=1.5, color=lineColor, label=labelRefl)
        plt.legend()
        done = input('Done? ')                                                                                          #are you done w/ reference lines?
        if done == 'yes':                                                                                               #if yes show plot and stop looping through statement
            plt.show()
            break

    plt.show()
开发者ID:RadhaRamachandran,项目名称:RDCEP-summer-scholars-2015,代码行数:26,代码来源:GraphAny.py


示例20: barChart

def barChart(title="Nothing"):
	dataY = [-8.51,0.27,0.52] #Import data from csv
	dataX = ['Energy For Production','GDP','Household Consumption']
	n_groups = len(dataX)
	index = np.arange(n_groups)
	bar_width = 0.4
	width = 0.8
	fig,a = plt.subplots()
	plt.axhline(y = 0,xmin=0,xmax=4,linewidth = 2) #for horizontal line plotting
	# p1=a.bar(dataY	,dataX)
	p1 = plt.bar(index,dataY,bar_width,alpha=0.4,color='b')
	plt.title(title)
	plt.xticks(index + bar_width/2, dataX)
	print(a.get_position())

	def autolabel(rects):
		for rect in rects:
			height = rect.get_height()
			#-ve rect height??
			a.text(rect.get_x() + rect.get_width()/2., 1.05*height,
						'%f' % float(height),
						ha='center', va='bottom')
	autolabel(p1)
	plt.legend()
	plt.tight_layout()
	plt.show()
开发者ID:akshay0193,项目名称:rebound_Charts,代码行数:26,代码来源:charts.py



注:本文中的matplotlib.pyplot.axhline函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pyplot.axhspan函数代码示例发布时间:2022-05-27
下一篇:
Python pyplot.axes函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap