当前位置: 首页>>代码示例>>Python>>正文


Python pyplot.minorticks_on方法代码示例

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


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

示例1: plot_logs

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import minorticks_on [as 别名]
def plot_logs(logs, score_name="top1", y_max=1, prefix=None, score_type=None):
    """
    Args:
        score_type (str): label for current curve, [valid|train|aggreg]
    """

    # Plot all losses
    scores = logs[score_name]
    if score_type is None:
        label = prefix + ""
    else:
        label = prefix + "_" + score_type.lower()

    plt.plot(scores, label=label)
    plt.title(score_name)
    if score_name == "top1" or score_name == "top1_action":
        # Set maximum for y axis
        plt.minorticks_on()
        x1, x2, _, _ = plt.axis()
        axes = plt.gca()
        axes.yaxis.set_minor_locator(MultipleLocator(0.02))
        plt.axis((x1, x2, 0, y_max))
        plt.grid(b=True, which="minor", color="k", alpha=0.2, linestyle="-")
        plt.grid(b=True, which="major", color="k", linestyle="-") 
开发者ID:hassony2,项目名称:obman_train,代码行数:26,代码来源:logutils.py

示例2: plot_autocorrelation

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import minorticks_on [as 别名]
def plot_autocorrelation(chain, interval=2, max_lag=100, radius=1.1):
    if max_lag is None:
        max_lag = chain.size()
    autocorrelations = chain.autocorrelations()[:max_lag]
    lags = np.arange(0, max_lag, interval)
    autocorrelations = autocorrelations[lags]
    plt.ylim([-radius, radius])
    center = .5
    for index, lag in enumerate(lags):
        autocorrelation = autocorrelations[index]
        plt.axvline(lag, center, center + autocorrelation / 2 / radius, c="black")
    plt.xlabel("Lag")
    plt.ylabel("Autocorrelation")
    plt.minorticks_on()
    plt.axhline(0, linestyle="--", c="black", alpha=.75, lw=2)
    make_square(plt.gca())
    figure = plt.gcf()

    return figure 
开发者ID:montefiore-ai,项目名称:hypothesis,代码行数:21,代码来源:mcmc.py

示例3: plotSeries

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import minorticks_on [as 别名]
def plotSeries(key, ymin=None, ymax=None):
    """
    Plot the chosen dataset key for each scanned data file.

    @param key: data set key to use
    @type key: L{str}
    @param ymin: minimum value for y-axis or L{None} for default
    @type ymin: L{int} or L{float}
    @param ymax: maximum value for y-axis or L{None} for default
    @type ymax: L{int} or L{float}
    """

    titles = []
    for title, data in sorted(dataset.items(), key=lambda x: x[0]):
        titles.append(title)
        x, y = zip(*[(k / 3600.0, v[key]) for k, v in sorted(data.items(), key=lambda x: x[0]) if key in v])

        plt.plot(x, y)

    plt.xlabel("Hours")
    plt.ylabel(key)
    plt.xlim(0, 24)
    if ymin is not None:
        plt.ylim(ymin=ymin)
    if ymax is not None:
        plt.ylim(ymax=ymax)
    plt.xticks(
        (1, 4, 7, 10, 13, 16, 19, 22,),
        (18, 21, 0, 3, 6, 9, 12, 15,),
    )
    plt.minorticks_on()
    plt.gca().xaxis.set_minor_locator(AutoMinorLocator(n=3))
    plt.grid(True, "major", "x", alpha=0.5, linewidth=0.5)
    plt.grid(True, "minor", "x", alpha=0.5, linewidth=0.5)
    plt.legend(titles, 'upper left', shadow=True, fancybox=True)
    plt.show() 
开发者ID:apple,项目名称:ccs-calendarserver,代码行数:38,代码来源:statsanalysis.py

示例4: show

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import minorticks_on [as 别名]
def show(dsName, subType):
    wName = '../Weights/' + branchName() + '_' + dsName + '_' + subType

    cnn = 1
    if cnn == 1:
        mc = ModelContainer_CNN(Model_CNN_0(dsName))
        mc.load_weights(wName + '_best', train=False)
        train_loss, val_loss = mc.getLossHistory()
    else:
        mc = GuessNet()
        checkPoint = torch.load(wName + '.pt')
        mc.load_state_dict(checkPoint['model_state_dict'])
        mc.load_state_dict(checkPoint['optimizer_state_dict'])
        train_loss = checkPoint['train_loss']
        val_loss = checkPoint['val_loss']





    plt.figure()
    train_line, =plt.plot(train_loss, 'r-o')
    val_line, =plt.plot(val_loss, 'b-o')
    plt.legend((train_line, val_line),('Train Loss', 'Validation Loss'))
    # if dsName.lower() == 'airsim':
    #     plt.title('Mahalanobis Distance ' + dsName + ' Pincushion Distortion')
    # else:
    #     plt.title('Mahalanobis Distance ' + dsName)
    plt.grid(b=True, which='major', color='#666666', linestyle='-')
    plt.minorticks_on()
    plt.grid(b=True, which='minor', color='#999999', linestyle='-', alpha=0.2)
    plt.ylim(bottom=0, top=10)
    plt.ylabel('Mahalanobis Distance, m', fontsize=20)
    plt.xlabel('Epochs', fontsize=20)
    plt.savefig('trainResult.png')
    plt.show() 
开发者ID:ElliotHYLee,项目名称:Deep_Visual_Inertial_Odometry,代码行数:38,代码来源:ShowTrainResult.py

示例5: plot_trace

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import minorticks_on [as 别名]
def plot_trace(chain, parameter_index=None):
    nrows = chain.dimensionality()
    figure, rows = plt.subplots(nrows, 2, sharey=False, sharex=False, figsize=(2 * 7, 2))
    num_samples = chain.size()
    def display(ax_trace, ax_density, theta_index=1):
        # Trace
        ax_trace.minorticks_on()
        ax_trace.plot(range(num_samples), chain.samples.numpy(), color="black", lw=2)
        ax_trace.set_xlim([0, num_samples])
        ax_trace.set_xticks([])
        ax_trace.set_ylabel(r"$\theta_" + str(theta_index) + "$")
        limits = ax_trace.get_ylim()
        # Density
        ax_density.minorticks_on()
        ax_density.hist(chain.samples.numpy(), bins=50, lw=2, color="black", histtype="step", density=True)
        ax_density.yaxis.tick_right()
        ax_density.yaxis.set_label_position("right")
        ax_density.set_ylabel("Probability mass function")
        ax_density.set_xlabel(r"$\theta_" + str(theta_index) + "$")
        ax_density.set_xlim(limits)
        # Aspects
        make_square(ax_density)
        ax_trace.set_aspect("auto")
        ax_trace.set_position([0, 0, .7, 1])
        ax_density.set_position([.28, 0, 1, 1])
    if nrows > 1:
        for index, ax_trace, ax_density in enumerate(rows):
            display(ax_trace, ax_density)
    else:
        ax_trace, ax_density = rows
        display(ax_trace, ax_density)

    return figure 
开发者ID:montefiore-ai,项目名称:hypothesis,代码行数:35,代码来源:mcmc.py

示例6: standard_plot

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import minorticks_on [as 别名]
def standard_plot(
    SCADA_good, SCADA_fault, title='Power Curve Plot',
        temp=False):

    # plot it all
    plt.figure(figsize=(40, 20))

    # up/down plot
    # good and bad points
    if temp is True:
        ava_good_temp = (SCADA_good['CS101__Nacelle_ambient_temp_1'] +
                         SCADA_good['CS101__Nacelle_ambient_temp_2']) / 2
        ava_fault_temp = (SCADA_fault['CS101__Nacelle_ambient_temp_1'] +
                          SCADA_fault['CS101__Nacelle_ambient_temp_2']) / 2
        good_colour = ava_good_temp
        bad_colour = ava_fault_temp
    else:
        good_colour = 'b'
        bad_colour = 'r'

    good_plt = plt.scatter(
        SCADA_good['WEC_ava_windspeed'], SCADA_good['WEC_ava_Power'],
        c=good_colour, cmap=plt.cm.Blues, linewidth='0', s=50)
    fault_plt = plt.scatter(
        SCADA_fault['WEC_ava_windspeed'], SCADA_fault['WEC_ava_Power'],
        c=bad_colour, cmap=plt.cm.Reds, linewidth='0', s=50)

    # put a grid on it
    plt.grid(b=True, which='major', color='b', linestyle='-')
    plt.minorticks_on()
    plt.grid(b=True, which='minor', color='r', linestyle='--')

    # legend, title, colorbar
    plt.legend(loc='upper left')
    plt.title(title)

    if temp:
        plt.colorbar(good_plt)

    plt.show()


# --------------------SVM Functions------------------------------------- 
开发者ID:lkev,项目名称:wt-fdd,代码行数:45,代码来源:importandfilter.py

示例7: plot_charts

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import minorticks_on [as 别名]
def plot_charts(modelLoc):
  fileObj = open("./" + modelLoc + "/log.txt", 'r')

  epoch = []
  trainLoss = []
  trainScore = []
  valLoss = []
  valScore = []

  # Read in File
  for line in fileObj:
    words = line.split()
    if words[0] == 'epoch':
      epoch.append(int(words[1][:-1]))
    elif words[0] == 'train_loss:':
      trainLoss.append(float(words[1][:-1]))
      trainScore.append(float(words[3]))
    elif words[0] == 'eval':
      valLoss.append(float(words[2][:-1]))
      valScore.append(float(words[4]))

  fileObj.close()

  minValLoss = min(valLoss)
  epochValLoss = np.argmin(valLoss)
  maxValScore = max(valScore)
  epochValScore = np.argmax(valScore)

  # Plot Loss and Score
  plt.figure()
  plt.suptitle(modelLoc)

  # train/val loss
  plt.subplot(211)
  plt.plot(epoch, trainLoss, label='Training')
  plt.plot(epoch, valLoss, label='Validation')
  plt.plot(epochValLoss, minValLoss, marker='x', markersize=3, color="black")
  plt.xlabel('loss')
  plt.ylabel('score')
  plt.title('Training and Validation Loss')
  plt.legend()
  plt.minorticks_on()
  plt.grid(True, which='both')

  # train/val score
  plt.subplot(212)
  plt.plot(epoch, trainScore, label='Training')
  plt.plot(epoch, valScore, label='Validation')
  plt.plot(epochValScore, maxValScore, marker='x', markersize=3, color="black")
  plt.xlabel('epochs')
  plt.ylabel('score')
  plt.title('Training and Validation Score')
  plt.legend()
  plt.minorticks_on()
  plt.grid(True, which='both')

  plt.subplots_adjust(hspace=0.5)
  #plt.show()
  plt.savefig("./" + modelLoc + ".png") 
开发者ID:SinghJasdeep,项目名称:Attention-on-Attention-for-VQA,代码行数:61,代码来源:plot.py

示例8: frame_average_radprofile

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import minorticks_on [as 别名]
def frame_average_radprofile(frame, sep=1, init_rad=None, plot=True):
    """ Calculates the average radial profile of an image.

    Parameters
    ----------
    frame : numpy ndarray
        Input image or 2d array.
    sep : int, optional
        The average radial profile is recorded every ``sep`` pixels.
    plot : bool, optional
        If True the profile is plotted.

    Returns
    -------
    df : dataframe
        Pandas dataframe with the radial profile and distances.

    Notes
    -----
    https://stackoverflow.com/questions/21242011/most-efficient-way-to-calculate-radial-profile
    https://stackoverflow.com/questions/48842320/what-is-the-best-way-to-calculate-radial-average-of-the-image-with-python
    https://github.com/keflavich/image_tools/blob/master/image_tools/radialprofile.py

    """
    check_array(frame, dim=2)
    cy, cx = frame_center(frame)

    if init_rad is None:
        init_rad = 1
    x, y = np.indices((frame.shape))
    r = np.sqrt((x - cx) ** 2 + (y - cy) ** 2)
    r = r.astype(int)
    tbin = np.bincount(r.ravel(), frame.ravel())
    nr = np.bincount(r.ravel())
    radprofile = tbin / nr

    radists = np.arange(init_rad + 1, int(cy), sep) - 1
    radprofile_radists = radprofile[radists]
    nr_radists = nr[radists]
    df = pd.DataFrame({'rad': radists, 'radprof': radprofile_radists,
                       'npx': nr_radists})

    if plot:
        plt.figure(figsize=vip_figsize)
        plt.plot(radists, radprofile_radists, '.-', alpha=0.6)
        plt.grid(which='both', alpha=0.4)
        plt.xlabel('Pixels')
        plt.ylabel('Counts')
        plt.minorticks_on()
        plt.xlim(0)

    return df 
开发者ID:vortex-exoplanet,项目名称:VIP,代码行数:54,代码来源:im_stats.py


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