Skip to content

Commit

Permalink
Backport PR matplotlib#28836: MNT: Use __init__ parameters of font pr…
Browse files Browse the repository at this point in the history
…operties
  • Loading branch information
QuLogic authored and meeseeksmachine committed Sep 19, 2024
1 parent e528a38 commit ae85b62
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
17 changes: 5 additions & 12 deletions galleries/examples/text_labels_and_annotations/fonts_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,43 +21,36 @@
fig.text(0.1, 0.9, 'family', fontproperties=heading_font, **alignment)
families = ['serif', 'sans-serif', 'cursive', 'fantasy', 'monospace']
for k, family in enumerate(families):
font = FontProperties()
font.set_family(family)
font = FontProperties(family=[family])
fig.text(0.1, yp[k], family, fontproperties=font, **alignment)

# Show style options
styles = ['normal', 'italic', 'oblique']
fig.text(0.3, 0.9, 'style', fontproperties=heading_font, **alignment)
for k, style in enumerate(styles):
font = FontProperties()
font.set_family('sans-serif')
font.set_style(style)
font = FontProperties(family='sans-serif', style=style)
fig.text(0.3, yp[k], style, fontproperties=font, **alignment)

# Show variant options
variants = ['normal', 'small-caps']
fig.text(0.5, 0.9, 'variant', fontproperties=heading_font, **alignment)
for k, variant in enumerate(variants):
font = FontProperties()
font.set_family('serif')
font.set_variant(variant)
font = FontProperties(family='serif', variant=variant)
fig.text(0.5, yp[k], variant, fontproperties=font, **alignment)

# Show weight options
weights = ['light', 'normal', 'medium', 'semibold', 'bold', 'heavy', 'black']
fig.text(0.7, 0.9, 'weight', fontproperties=heading_font, **alignment)
for k, weight in enumerate(weights):
font = FontProperties()
font.set_weight(weight)
font = FontProperties(weight=weight)
fig.text(0.7, yp[k], weight, fontproperties=font, **alignment)

# Show size options
sizes = [
'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large']
fig.text(0.9, 0.9, 'size', fontproperties=heading_font, **alignment)
for k, size in enumerate(sizes):
font = FontProperties()
font.set_size(size)
font = FontProperties(size=size)
fig.text(0.9, yp[k], size, fontproperties=font, **alignment)

# Show bold italic
Expand Down
5 changes: 1 addition & 4 deletions galleries/users_explain/text/text_intro.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,7 @@

from matplotlib.font_manager import FontProperties

font = FontProperties()
font.set_family('serif')
font.set_name('Times New Roman')
font.set_style('italic')
font = FontProperties(family='Times New Roman', style='italic')

fig, ax = plt.subplots(figsize=(5, 3))
fig.subplots_adjust(bottom=0.15, left=0.2)
Expand Down

0 comments on commit ae85b62

Please sign in to comment.