How to use the matplotlib.pyplot.ylim function in matplotlib

To help you get started, we’ve selected a few matplotlib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cigroup-ol / windml / examples / missingdata / mar_damaged.py View on Github external
d_time_hat = []
for i in range (len(d_hat)):
    d_act_hat = datetime.datetime.fromtimestamp(d_hat[i])
    d_time_hat.append(d_act_hat)

with plt.style.context("fivethirtyeight"):
    figure = plt.figure(figsize=(15, 10))
    plt.subplots_adjust(bottom=0.25)
    plt.xticks(rotation = 75)
    
    ax=plt.gca()
    xfmt = md.DateFormatter('%Y/%m/%d %H-h')
    ax.xaxis.set_major_formatter(xfmt)
    
    ax.grid(True)
    plt.ylim(-2, 32)
    plt.ylabel("Corrected Power (MW), Wind Speed (m/s)")
    
    plt.plot(d_time, y1, label = 'Power Production', color="b", alpha=0.5)
    plt.plot(d_time, y2, label = 'Wind Speed', color="g", alpha=0.5)
    
    plt.plot(d_time_hat, y1_hat, label = 'Power Production (damaged)',
        color="b", linestyle="-.", marker="o")
    plt.plot(d_time_hat, y2_hat, label = 'Wind Speed (damaged)', color="g",
        marker="o", linestyle="-.")
    
    plt.legend(loc='lower right')
    plt.title("Timeseries of the Selected Turbine")
    
    plt.show()
github virtool / virtool / virtool / plots.py View on Github external
"#3C763D", # Thymine
        "#777777", # Cytosine
    ]

    for i in range(0, 4):
        data = [pnt[i] for pnt in composition]

        plt.plot(range(1, len(data) + 1), data, color=colors[i])
        plt.plot(range(1, len(data) + 1), data, color=colors[i])
        plt.plot(range(1, len(data) + 1), data, color=colors[i])
        plt.plot(range(1, len(data) + 1), data, color=colors[i])

    plt.title('Nucleotide Composition')
    plt.xlabel('Read Position (bp)')
    plt.ylabel('Composition (%)')
    plt.ylim(0, 100)
    plt.xlim(1, len(composition))
    plt.tight_layout()

    handles = [mpatches.Patch(color=colors[i], label=labels[i]) for i in range(0, 4)]

    plt.legend(handles=handles, prop={"size": 6})
github Parallel-in-Time / pySDC / pySDC / projects / node_failure / postproc_hard_faults_detail.py View on Github external
plt.plot(xvals, [-9 for _ in range(maxiter)], 'k--')
    plt.annotate('tolerance', xy=(1, -9.4), fontsize=fs)

    left = 6.15
    bottom = -12
    width = 0.7
    height = 12
    right = left + width
    top = bottom + height
    rect = plt.Rectangle(xy=(left, bottom), width=width, height=height, color='lightgrey')
    plt.text(0.5 * (left + right), 0.5 * (bottom + top), 'node failure', horizontalalignment='center',
             verticalalignment='center', rotation=90, color='k', fontsize=fs)
    fig.gca().add_artist(rect)

    plt.xlim(1 - 0.25, maxiter + 0.25)
    plt.ylim(minres - 0.25, maxres + 0.25)

    plt.xlabel('iteration', **axis_font)
    plt.ylabel('log10(residual)', **axis_font)
    plt.title('ALL', **axis_font)
    ax.xaxis.labelpad = 0
    ax.yaxis.labelpad = 0
    plt.tick_params(axis='both', which='major', labelsize=fs)

    plt.legend(numpoints=1, fontsize=fs)

    plt.xticks(range(1, maxiter + 1))
    plt.yticks(range(minres, maxres + 1))

    ax.tick_params(pad=2)

    # plt.tight_layout()
github tkianai / ICDAR2019-tools / eval.py View on Github external
def save_pr_curve(self, save_name='./data/P_R_curve.png'):
        if self.Precision is None or self.Recall is None:
            return

        # save the P-R curve
        save_dir = os.path.dirname(save_name)
        if not os.path.exists(save_dir):
            os.makedirs(save_dir)
        
        plt.clf()
        plt.plot(self.Recall, self.Precision)
        plt.xlim(0, 1)
        plt.ylim(0, 1)
        plt.title('Precision-Recall Curve')
        plt.grid()
        plt.xlabel('Recall')
        plt.ylabel('Precision')
        plt.savefig(save_name, dpi=400)
        print('Precision-recall curve has been written to {}'.format(save_name))
github jsonbruce / MTSAnomalyDetection / ensemblation / processor.py View on Github external
def plot_prc(file_name, precisions, recalls, average_precision):
        # Plot P-R curve
        plt.figure(figsize=(16, 9))
        plt.plot(recalls, precisions)
        plt.xlabel('Recall')
        plt.ylabel('Precision')
        plt.ylim([0.0, 1.05])
        plt.xlim([0.0, 1.05])
        plt.title('Precision-Recall curve: AUC={0:0.2f}'.format(average_precision))
        plt.savefig("result/%s-pr.png" % file_name)
github GeoscienceAustralia / tcrm / eval / evaluate.py View on Github external
self.gateLats[:-1], color='r', lw=2)
                     
            ax1.plot(2 * self.gateLons[i] - self.lonCrossingSynEWMean[:, i], \
                     self.gateLats[:-1],color='k',lw=2)
                     
            x1 = 2 * self.gateLons[i] - self.lonCrossingSynEWUpper[:, i]
            x2 = 2 * self.gateLons[i] - self.lonCrossingSynEWLower[:, i]
            ax1.fill_betweenx(self.gateLats[:-1], x1, x2, 
                              color='0.5', alpha=0.5)

        minLonLim = 2 * self.minLon
        maxLonLim = 2 * self.maxLon + 20.
        pyplot.xlim(minLonLim, maxLonLim)
        pyplot.xticks(2 * self.gateLons, self.gateLons.astype(int), fontsize=8)
        pyplot.xlabel("East-west crossings")
        pyplot.ylim(self.gateLats.min(), self.gateLats[-2])
        pyplot.yticks(fontsize=8)
        pyplot.ylabel('Latitude')
        ax1.tick_params(direction='out', top='off', right='off')
        pyplot.grid(True)

        ax2 = pyplot.subplot(212)
        for i in range(len(self.gateLons)):
            ax2.plot(2 * self.gateLons[i] + self.lonCrossingWEHist[:, i] * \
                     self.synNumYears / self.historicNumYears,
                     self.gateLats[:-1], color='r', lw=2)
                     
            ax2.plot(2 * self.gateLons[i] + self.lonCrossingSynWEMean[:, i],
                     self.gateLats[:-1], color='k', lw=2)
                     
            x1 = 2 * self.gateLons[i] + self.lonCrossingSynWEUpper[:, i]
            x2 = 2 * self.gateLons[i] + self.lonCrossingSynWELower[:, i]
github nextgenusfs / funannotate / lib / library.py View on Github external
#set up plot
    sns.set_style('darkgrid')
    sns.set_context('paper')
    fig = plt.figure()
    ax = fig.add_subplot(111)
    YLabel = "Number of "+type
    SBG.stackedBarPlot(ax,panda,color_palette,xLabels=panda.index.values,endGaps=True,gap=0.25,xlabel="Genomes",ylabel=YLabel,yTicks=yticks) 
    plt.title(type+" summary")
    #get the legend
    legends = [] 
    i = 0 
    for column in panda.columns: 
        legends.append(mpatches.Patch(color=color_palette[i], label=panda.columns.values[i]+ ": " + labels.get(panda.columns.values[i]))) 
        i+=1 
    lgd = ax.legend(handles=legends, fontsize=6, loc='upper left', bbox_to_anchor=(1.02, 1), borderaxespad=0)
    plt.ylim([0,ymax]) 
    #set the font size - i wish I knew how to do this proportionately.....but setting to something reasonable.
    for item in ax.get_xticklabels():
        item.set_fontsize(8)
    #setup the plot
    fig.subplots_adjust(bottom=0.4)
    fig.savefig(output, format='pdf', bbox_extra_artists=(lgd,), bbox_inches='tight')
    plt.close(fig)
github tuomasr / robust / robust.py View on Github external
print 'Converged at iteration %d! Gap: %s' % (iteration, GAP)
else:
	print 'Did not converge. Gap: ', GAP

print separator
print 'Objective value:', master_problem.objVal
print 'Investment cost %s, operation cost %s ' % (get_investment_cost(x, y), subproblem.objVal)
print separator

plot_gap = False

if plot_gap:
	from matplotlib import pyplot as plt

	plt.plot(gaps)
	plt.ylim(np.amin(gaps), 1e-2)
	plt.ylabel('GAP')
	plt.xlabel('iteration')
	plt.show()
github nanophotonics / nplab / nplab / analysis / DF_Multipeakfitbeta.py View on Github external
elif len(yMaxes) == 1:
            title = 'Single Peak'

        elif len(yMaxes) < 1:
            title = 'No Peak'

        plt.figure(figsize = (8, 6))
        plt.plot(x, y, 'purple', lw = 0.3, label = 'Raw')
        plt.xlabel('Wavelength (nm)', fontsize = 14)
        plt.ylabel('Intensity', fontsize = 14)
        plt.plot(xTrunc, ySmooth, 'g', label = 'Smoothed')
        plt.plot(x2, y2,'k', label = 'Truncated')
        #plt.plot(xMins, yMins, 'ko', label = 'Minima')
        #plt.plot(xMaxes, yMaxes, 'go', label = 'Maxima in CM Region')
        plt.legend(loc = 0, ncol = 3, fontsize = 10)
        plt.ylim(0, ySmooth.max()*1.23)
        plt.xlim(450, 900)
        plt.title(title, fontsize = 16)
        plt.show()

    return isDouble
github MobleyLab / alchemical-analysis / alchemical_analysis / alchemical_analysis.py View on Github external
return getInd(ri[j:], z)

        xt = [i if (i in getInd()) else '' for i in range(K)]
        pl.xticks(xs[1:], xt[1:], fontsize=10)
        pl.yticks(fontsize=10)
        #ax = pl.gca()
        #for label in ax.get_xticklabels():
        #   label.set_bbox(dict(fc='w', ec='None', alpha=0.5))

        # Remove the abscissa ticks and set up the axes limits.
        for tick in ax.get_xticklines():
            tick.set_visible(False)
        pl.xlim(0, ndx)
        min_y *= 1.01
        max_y *= 1.01
        pl.ylim(min_y, max_y)

        for i,j in zip(xs[1:], xt[1:]):
            pl.annotate(('%.2f' % (i-1.0 if i>1.0 else i) if not j=='' else ''), xy=(i, 0), xytext=(i, 0.01), size=10, rotation=90, textcoords=('data', 'axes fraction'), va='bottom', ha='center', color='#151B54')
        if ndx>1:
            lenticks = len(ax.get_ymajorticklabels()) - 1
            if min_y<0: lenticks -= 1
            if lenticks < 5:
                from matplotlib.ticker import AutoMinorLocator as AML
                ax.yaxis.set_minor_locator(AML())
        pl.grid(which='both', color='w', lw=0.25, axis='y', zorder=12)
        pl.ylabel(r'$\mathrm{\langle{\frac{ \partial U } { \partial \lambda }}\rangle_{\lambda}\/%s}$' % P.units, fontsize=20, color='#151B54')
        pl.annotate('$\mathit{\lambda}$', xy=(0, 0), xytext=(0.5, -0.05), size=18, textcoords='axes fraction', va='top', ha='center', color='#151B54')

        if not P.software == 'sire':
            lege = ax.legend(prop=FP(size=14), frameon=False, loc=1)