Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Bug]:multialignment='right' inax.text() withpath_effects breaks when using LaTeX package\usepackage[T1]{fontenc} #28675

Closed
@yjzhu-solar

Description

@yjzhu-solar

Bug summary

When I plot a multiline text usingax.text() withpath_effects under TeX environment with package\usepackage[T1]{fontenc} the multiline coalignment to right breaks.

Code for reproduction

importmatplotlibprint(matplotlib.__version__)importmatplotlib.pyplotaspltfrommatplotlibimportrc_context,patheffectsaspath_effectsprint(matplotlib.get_backend())withrc_context({'text.usetex':True,'font.family':'serif','font.serif':'cm','text.latex.preamble':r'\usepackage[T1]{fontenc}'                 }):fig,ax=plt.subplots(layout='constrained')text1=ax.text(0,0.95,r'\textbf{aaaaaaaaaaaaaaa}'"\n"+r'\textbf{{\quad\textsc{aaaaaa}}}',transform=ax.transAxes,fontsize=12,va='top',ha='left',linespacing=1.2,ma='left',color='green', )text2=ax.text(0,0.8,r'\textbf{aa}'"\n"+r'\textbf{{aaaaaaaaaaaaaaa}}',transform=ax.transAxes,fontsize=12,va='top',ha='left',linespacing=1.2,ma='right',color='red',path_effects=[path_effects.Stroke(linewidth=1.2,foreground='black'),path_effects.Normal()])text3=ax.text(1,0.95,r'\textbf{aa}'"\n"+r'\textbf{{aaaaaaaaaaaaaaa}}',transform=ax.transAxes,fontsize=12,va='top',ha='right',linespacing=1.2,ma='right',color='red',)text4=ax.text(1,0.8,r'\textbf{aa}'"\n"+r'\textbf{{aaaaaaaaaaaaaaa}}',transform=ax.transAxes,fontsize=12,va='top',ha='right',linespacing=1.2,ma='right',color='red',path_effects=[path_effects.Stroke(linewidth=1.2,foreground='black'),path_effects.Normal()])ax.set_title(r'With \textbackslash usepackage[T1]\{fontenc\}')plt.show()withrc_context({'text.usetex':True,'font.family':'serif','font.serif':'cm',                 }):fig,ax=plt.subplots(layout='constrained')text1=ax.text(0,0.95,r'\textbf{aaaaaaaaaaaaaaa}'"\n"+r'\textbf{{\quad\textsc{aaaaaa}}}',transform=ax.transAxes,fontsize=12,va='top',ha='left',linespacing=1.2,ma='left',color='green', )text2=ax.text(0,0.8,r'\textbf{aa}'"\n"+r'\textbf{{aaaaaaaaaaaaaaa}}',transform=ax.transAxes,fontsize=12,va='top',ha='left',linespacing=1.2,ma='right',color='red',path_effects=[path_effects.Stroke(linewidth=1.2,foreground='black'),path_effects.Normal()])text3=ax.text(1,0.95,r'\textbf{aa}'"\n"+r'\textbf{{aaaaaaaaaaaaaaa}}',transform=ax.transAxes,fontsize=12,va='top',ha='right',linespacing=1.2,ma='right',color='red',)text4=ax.text(1,0.8,r'\textbf{aa}'"\n"+r'\textbf{{aaaaaaaaaaaaaaa}}',transform=ax.transAxes,fontsize=12,va='top',ha='right',linespacing=1.2,ma='right',color='red',path_effects=[path_effects.Stroke(linewidth=1.2,foreground='black'),path_effects.Normal()])ax.set_title(r'Without \textbackslash usepackage[T1]\{fontenc\}')plt.show()

Actual outcome

Thema='right' breaks for the bottom two texts withpath_effects.
image

Expected outcome

I would expect something similar without\usepackage[T1]{fontenc} below, but somehow I really want to include it because it provides some additional support, for example, nesting\textsc{} in\textbf{}.
image

Additional information

No response

Operating system

WSL 2.2.4.0/Ubuntu 22.04.3 LTS

Matplotlib Version

3.9.1

Matplotlib Backend

qtagg

Python version

3.12.2

Jupyter version

No response

Installation

None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp