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


Python patheffects.Normal方法代码示例

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


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

示例1: test_patheffect1

# 需要导入模块: from matplotlib import patheffects [as 别名]
# 或者: from matplotlib.patheffects import Normal [as 别名]
def test_patheffect1():
    ax1 = plt.subplot(111)
    ax1.imshow([[1, 2], [2, 3]])
    txt = ax1.annotate("test", (1., 1.), (0., 0),
                       arrowprops=dict(arrowstyle="->",
                                       connectionstyle="angle3", lw=2),
                       size=20, ha="center",
                       path_effects=[path_effects.withStroke(linewidth=3,
                                                             foreground="w")])
    txt.arrow_patch.set_path_effects([path_effects.Stroke(linewidth=5,
                                                          foreground="w"),
                                      path_effects.Normal()])

    ax1.grid(True, linestyle="-")

    pe = [path_effects.withStroke(linewidth=3, foreground="w")]
    for l in ax1.get_xgridlines() + ax1.get_ygridlines():
        l.set_path_effects(pe) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:20,代码来源:test_patheffects.py

示例2: test_patheffect3

# 需要导入模块: from matplotlib import patheffects [as 别名]
# 或者: from matplotlib.patheffects import Normal [as 别名]
def test_patheffect3():
    p1, = plt.plot([1, 3, 5, 4, 3], 'o-b', lw=4)
    p1.set_path_effects([path_effects.SimpleLineShadow(),
                         path_effects.Normal()])
    plt.title(r'testing$^{123}$',
        path_effects=[path_effects.withStroke(linewidth=1, foreground="r")])
    leg = plt.legend([p1], [r'Line 1$^2$'], fancybox=True, loc=2)
    leg.legendPatch.set_path_effects([path_effects.withSimplePatchShadow()])

    text = plt.text(2, 3, 'Drop test', color='white',
                    bbox={'boxstyle': 'circle,pad=0.1', 'color': 'red'})
    pe = [path_effects.Stroke(linewidth=3.75, foreground='k'),
          path_effects.withSimplePatchShadow((6, -3), shadow_rgbFace='blue')]
    text.set_path_effects(pe)
    text.get_bbox_patch().set_path_effects(pe)

    pe = [path_effects.PathPatchEffect(offset=(4, -4), hatch='xxxx',
                                       facecolor='gray'),
          path_effects.PathPatchEffect(edgecolor='white', facecolor='black',
                                       lw=1.1)]

    t = plt.gcf().text(0.02, 0.1, 'Hatch shadow', fontsize=75, weight=1000,
                       va='center')
    t.set_path_effects(pe) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:26,代码来源:test_patheffects.py

示例3: test_PathEffect_points_to_pixels

# 需要导入模块: from matplotlib import patheffects [as 别名]
# 或者: from matplotlib.patheffects import Normal [as 别名]
def test_PathEffect_points_to_pixels():
    fig = plt.figure(dpi=150)
    p1, = plt.plot(range(10))
    p1.set_path_effects([path_effects.SimpleLineShadow(),
                         path_effects.Normal()])

    renderer = fig.canvas.get_renderer()
    pe_renderer = path_effects.SimpleLineShadow().get_proxy_renderer(renderer)

    assert isinstance(pe_renderer, path_effects.PathEffectRenderer), (
                'Expected a PathEffectRendere instance, got '
                'a {} instance.'.format(type(pe_renderer)))

    # Confirm that using a path effects renderer maintains point sizes
    # appropriately. Otherwise rendered font would be the wrong size.
    assert_equal(renderer.points_to_pixels(15),
                 pe_renderer.points_to_pixels(15)) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:19,代码来源:test_patheffects.py

示例4: test_patheffect3

# 需要导入模块: from matplotlib import patheffects [as 别名]
# 或者: from matplotlib.patheffects import Normal [as 别名]
def test_patheffect3():
    p1, = plt.plot([1, 3, 5, 4, 3], 'o-b', lw=4)
    p1.set_path_effects([path_effects.SimpleLineShadow(),
                         path_effects.Normal()])
    plt.title(r'testing$^{123}$',
        path_effects=[path_effects.withStroke(linewidth=1, foreground="r")])
    leg = plt.legend([p1], [r'Line 1$^2$'], fancybox=True, loc='upper left')
    leg.legendPatch.set_path_effects([path_effects.withSimplePatchShadow()])

    text = plt.text(2, 3, 'Drop test', color='white',
                    bbox={'boxstyle': 'circle,pad=0.1', 'color': 'red'})
    pe = [path_effects.Stroke(linewidth=3.75, foreground='k'),
          path_effects.withSimplePatchShadow((6, -3), shadow_rgbFace='blue')]
    text.set_path_effects(pe)
    text.get_bbox_patch().set_path_effects(pe)

    pe = [path_effects.PathPatchEffect(offset=(4, -4), hatch='xxxx',
                                       facecolor='gray'),
          path_effects.PathPatchEffect(edgecolor='white', facecolor='black',
                                       lw=1.1)]

    t = plt.gcf().text(0.02, 0.1, 'Hatch shadow', fontsize=75, weight=1000,
                       va='center')
    t.set_path_effects(pe) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:26,代码来源:test_patheffects.py

示例5: test_patheffects_stroked_text

# 需要导入模块: from matplotlib import patheffects [as 别名]
# 或者: from matplotlib.patheffects import Normal [as 别名]
def test_patheffects_stroked_text():
    text_chunks = [
        'A B C D E F G H I J K L',
        'M N O P Q R S T U V W',
        'X Y Z a b c d e f g h i j',
        'k l m n o p q r s t u v',
        'w x y z 0123456789',
        r"!@#$%^&*()-=_+[]\;'",
        ',./{}|:"<>?'
    ]
    font_size = 50

    ax = plt.axes([0, 0, 1, 1])
    for i, chunk in enumerate(text_chunks):
        text = ax.text(x=0.01, y=(0.9 - i * 0.13), s=chunk,
                       fontdict={'ha': 'left', 'va': 'center',
                                 'size': font_size, 'color': 'white'})

        text.set_path_effects([path_effects.Stroke(linewidth=font_size / 10,
                                                   foreground='black'),
                               path_effects.Normal()])

    ax.set_xlim(0, 1)
    ax.set_ylim(0, 1)
    ax.axis('off') 
开发者ID:holzschu,项目名称:python3_ios,代码行数:27,代码来源:test_patheffects.py

示例6: drawRequestOnTimeline

# 需要导入模块: from matplotlib import patheffects [as 别名]
# 或者: from matplotlib.patheffects import Normal [as 别名]
def drawRequestOnTimeline(ticks,messagesbyTime,i=0):
    
    fig, ax = plt.subplots(figsize=(8.0,4.0))
    ax.plot(ticks, messagesbyTime, '-',color='#756bb1',alpha=1.,linewidth=2)
    
    z = np.polyfit(ticks, messagesbyTime, 10)
    p = np.poly1d(z)
    
    ax1 = ax.plot(ticks,p(ticks),":",color='#c1bcdc',linewidth=6,label="Total num. of requests",path_effects=[pe.Stroke(linewidth=8, foreground='purple'), pe.Normal()])
    ax.set_xlabel("Simulation number: %i"%i, fontsize=12)
    ax.set_ylabel("QoS satisfaction \n (num. of requests)", fontsize=12)
    ax.tick_params(labelsize=10)
    #ax.set_xlim(-20,2020)
    #ax.set_ylim(0,120)
    #plt.legend([ax1,ax2,ax3],['Total num. of requests','Partition','ILP'],loc="upper right",fontsize=18)
    plt.legend(loc="lower left",fontsize=12)
    plt.tight_layout()
    #plt.savefig('TimeSerie_Requests-%i.pdf'%i, format='pdf', dpi=600) 
开发者ID:acsicuib,项目名称:YAFS,代码行数:20,代码来源:analyse_results_paper_v2.py

示例7: plot_result

# 需要导入模块: from matplotlib import patheffects [as 别名]
# 或者: from matplotlib.patheffects import Normal [as 别名]
def plot_result(embeds, labels, output_path):
    # vis, plot code from https://github.com/pangyupo/mxnet_center_loss
    num = len(labels)
    names = dict()
    for i in range(10):
        names[i] = str(i)
    palette = np.array(sns.color_palette("hls", 10))
    f = plt.figure(figsize=(8, 8))
    ax = plt.subplot(aspect='equal')
    sc = ax.scatter(embeds[:, 0], embeds[:, 1], lw=0, s=40,
                    c=palette[labels.astype(np.int)])
    ax.axis('off')
    ax.axis('tight')

    # We add the labels for each digit.
    txts = []
    for i in range(10):
        # Position of each label.
        xtext, ytext = np.median(embeds[labels == i, :], axis=0)
        txt = ax.text(xtext, ytext, names[i])
        txt.set_path_effects([
            PathEffects.Stroke(linewidth=5, foreground="w"),
            PathEffects.Normal()])
        txts.append(txt)
    plt.savefig(output_path) 
开发者ID:THUFutureLab,项目名称:gluon-face,代码行数:27,代码来源:utils.py

示例8: CameraImageSummary

# 需要导入模块: from matplotlib import patheffects [as 别名]
# 或者: from matplotlib.patheffects import Normal [as 别名]
def CameraImageSummary(frontal_images, run_segment_strings, figsize=(6, 4)):
  """Write frontal_images as tf.Summaries.

  Args:
    frontal_images: Float tensor of frontal camera images: Shape: [batch,
      height, width, depth]. Expected aspect ratio of 3:2 for visualization.
    run_segment_strings: Tensor of strings: Shape: [batch, 1].  The associated
      RunSegment proto for the batch.
    figsize: Tuple indicating size of camera image. Default is (6, 4)
    indicating a 3:2 aspect ratio for visualization.
  """
  # Parse the run segment strings to extract the run segment info.
  run_segment_ids = ExtractRunIds(run_segment_strings)

  def DrawCameraImage(fig, axes, frontal_image, run_segment_id):
    """Draw camera image for image summary."""
    plot.AddImage(
        fig=fig,
        axes=axes,
        data=frontal_image / 256.,
        show_colorbar=False,
        suppress_xticks=True,
        suppress_yticks=True)
    txt = axes.text(
        x=0.5,
        y=0.01,
        s=run_segment_id,
        color='blue',
        fontsize=14,
        transform=axes.transAxes,
        horizontalalignment='center')
    txt.set_path_effects([
        path_effects.Stroke(linewidth=3, foreground='lightblue'),
        path_effects.Normal()
    ])

  with plot.MatplotlibFigureSummary(
      'examples', figsize=figsize, max_outputs=10) as fig:
    # Plot raw frontal image samples for each example.
    fig.AddSubplot([frontal_images, run_segment_ids], DrawCameraImage) 
开发者ID:tensorflow,项目名称:lingvo,代码行数:42,代码来源:summary.py

示例9: scatter

# 需要导入模块: from matplotlib import patheffects [as 别名]
# 或者: from matplotlib.patheffects import Normal [as 别名]
def scatter(study_names, X, ax, title="population", norm=False):
    n_studies = X.shape[0]
    palette = np.array(sns.color_palette("hls", n_studies))

    sc = ax.scatter(X[:,0], X[:,1], lw=0, s=60, c=palette[np.arange(n_studies)])


    # add labels for each study
    txts = []

    X_range = X[:,0].max()-X[:,0].min()
    Y_range = X[:,1].max()-X[:,1].min()

    for i in range(n_studies):
        # note that the below magic numbers are for aesthetics
        # only and are simply based on (manual) fiddling!
        jitter = np.array([-.05*X_range, .03*Y_range])
        xtext, ytext = X[i, :] + jitter
        txt = ax.text(xtext, ytext, study_names[i], fontsize=9)
        txt.set_path_effects([PathEffects.Stroke(linewidth=5, foreground="w"), PathEffects.Normal()])
        txts.append(txt)

    ax.set_xlim(min(X[:,0])-.5*X_range, max(X[:,0])+.5*X_range)
    ax.set_ylim(min(X[:,1])-.1*Y_range, max(X[:,1])+.1*Y_range)
    ax.set_title(title)
    ax.set_xticks([])
    ax.set_yticks([])
    ax.axis('off')
    # also return palette for later use
    return sc, convert_to_RGB(palette[np.arange(n_studies)]) 
开发者ID:ijmarshall,项目名称:robotreviewer,代码行数:32,代码来源:pico_viz_robot.py

示例10: test_patheffect1

# 需要导入模块: from matplotlib import patheffects [as 别名]
# 或者: from matplotlib.patheffects import Normal [as 别名]
def test_patheffect1():
    ax1 = plt.subplot(111)
    ax1.imshow([[1, 2], [2, 3]])
    txt = ax1.annotate("test", (1., 1.), (0., 0),
                       arrowprops=dict(arrowstyle="->",
                                       connectionstyle="angle3", lw=2),
                       size=20, ha="center",
                       path_effects=[path_effects.withStroke(linewidth=3,
                                                             foreground="w")])
    txt.arrow_patch.set_path_effects([path_effects.Stroke(linewidth=5,
                                                          foreground="w"),
                                      path_effects.Normal()])

    pe = [path_effects.withStroke(linewidth=3, foreground="w")]
    ax1.grid(True, linestyle="-", path_effects=pe) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:17,代码来源:test_patheffects.py

示例11: test_PathEffect_points_to_pixels

# 需要导入模块: from matplotlib import patheffects [as 别名]
# 或者: from matplotlib.patheffects import Normal [as 别名]
def test_PathEffect_points_to_pixels():
    fig = plt.figure(dpi=150)
    p1, = plt.plot(range(10))
    p1.set_path_effects([path_effects.SimpleLineShadow(),
                         path_effects.Normal()])

    renderer = fig.canvas.get_renderer()
    pe_renderer = path_effects.SimpleLineShadow().get_proxy_renderer(renderer)

    assert isinstance(pe_renderer, path_effects.PathEffectRenderer)
    # Confirm that using a path effects renderer maintains point sizes
    # appropriately. Otherwise rendered font would be the wrong size.
    assert renderer.points_to_pixels(15) == pe_renderer.points_to_pixels(15) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:15,代码来源:test_patheffects.py

示例12: embedding2dplot

# 需要导入模块: from matplotlib import patheffects [as 别名]
# 或者: from matplotlib.patheffects import Normal [as 别名]
def embedding2dplot(data, labels, show_median=True, show_legend=True):
    '''2D embedding visualization.

    Modified from:
    https://beta.oreilly.com/learning/an-illustrated-introduction-to-the-t-sne-algorithm

    '''
    # We choose a color palette with seaborn.
    max_label = labels.max()
    palette = np.array(sns.color_palette("hls", max_label+1))
    # We create a scatter plot.
    fig = plt.figure(figsize=(8, 8))
    ax = plt.subplot(aspect='equal')
    sc = ax.scatter(data[:, 0], data[:, 1], lw=0, s=40,
                    c=palette[labels.astype(np.int)])
    plt.xlim(-25, 25)
    plt.ylim(-25, 25)
    ax.axis('off')
    ax.axis('tight')

    # We add the labels for each cluster.
    if show_median:
        txts = []
        for i in range(10):
            # Position of each label.
            xtext, ytext = np.median(data[labels == i, :], axis=0)
            txt = ax.text(xtext, ytext, str(i), fontsize=24)
            txt.set_path_effects([
                PathEffects.Stroke(linewidth=5, foreground="w"),
                PathEffects.Normal()])
            txts.append(txt)

    # Show labels as legend patches
    if show_legend:
        handles = _get_legend(palette, labels)
        ax.legend(handles=handles)
    return fig, ax, sc 
开发者ID:AgnezIO,项目名称:agnez,代码行数:39,代码来源:embedding.py

示例13: draw_outline

# 需要导入模块: from matplotlib import patheffects [as 别名]
# 或者: from matplotlib.patheffects import Normal [as 别名]
def draw_outline(o, lw):
    o.set_path_effects([patheffects.Stroke(
        linewidth=lw, foreground='black'), patheffects.Normal()]) 
开发者ID:Esri,项目名称:raster-deep-learning,代码行数:5,代码来源:util.py

示例14: apply_label

# 需要导入模块: from matplotlib import patheffects [as 别名]
# 或者: from matplotlib.patheffects import Normal [as 别名]
def apply_label(x, color, label,
	text_side='left',
	lw=False,
	x_align=0.0,
	y_align=0.04,
	contour_ratio=1.5,
	text_color=False,
	):
	if text_color:
		color=text_color
	ax = plt.gca()
	if not lw:
		lw = mpl.rcParams['lines.linewidth']
	if text_side == 'left':
		text = ax.text(x_align, y_align, label,
			fontweight="bold",
			color=color,
			horizontalalignment="left",
			va="bottom",
			# For diagnostic purposes, the rasterization workaround should be removed once we can identify why function execution in PythonTeX introduces enlarged bounding boxes.
			#bbox=dict(facecolor='red', alpha=0.5),
			transform=ax.transAxes,
			)
	if text_side == 'right':
		text = ax.text(1.0-x_align, y_align, label,
			fontweight="bold",
			color=color,
			horizontalalignment="right",
			va="bottom",
			# For diagnostic purposes, the rasterization workaround should be removed once we can identify why function execution in PythonTeX introduces enlarged bounding boxes.
			#bbox=dict(facecolor='red', alpha=0.5),
			rasterized=True,
			transform=ax.transAxes,
			)
	text.set_path_effects([path_effects.Stroke(linewidth=lw*contour_ratio, foreground='w'),
	       path_effects.Normal()]) 
开发者ID:IBT-FMI,项目名称:SAMRI,代码行数:38,代码来源:aggregate.py

示例15: show_video_subtitle

# 需要导入模块: from matplotlib import patheffects [as 别名]
# 或者: from matplotlib.patheffects import Normal [as 别名]
def show_video_subtitle(frames, subtitle):
    fig, ax = plt.subplots()
    fig.show()

    text = plt.text(0.5, 0.1, "", 
        ha='center', va='center', transform=ax.transAxes, 
        fontdict={'fontsize': 15, 'color':'white', 'fontweight': 500})
    text.set_path_effects([path_effects.Stroke(linewidth=3, foreground='black'),
        path_effects.Normal()])

    subs = subtitle.split()
    inc = max(len(frames)/(len(subs)+1), 0.01)

    i = 0
    img = None
    for frame in frames:
        sub = " ".join(subs[:int(i/inc)])

        text.set_text(sub)

        if img is None:
            img = plt.imshow(frame)
        else:
            img.set_data(frame)
        fig.canvas.draw()
        i += 1 
开发者ID:rizkiarm,项目名称:LipNet,代码行数:28,代码来源:visualization.py


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