FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

More cleanup to annotations tutorial. by anntzer · Pull Request #20531 · matplotlib/matplotlib · GitHub

Repository navigation

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (4) All 1 file type selected
Deleted files Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
23 changes: 12 additions & 11 deletions examples/shapes_and_collections/fancybox_demo.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
The following examples show how to plot boxes with different visual properties.
"""

import inspect

import matplotlib.pyplot as plt
import matplotlib.transforms as mtransforms
import matplotlib.patches as mpatch
Expand All @@ -15,17 +17,16 @@
# First we'll show some sample boxes with fancybox.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
# First we'll show some sample boxes with fancybox.
# The following box styles are available:


styles = mpatch.BoxStyle.get_styles()
spacing = 1.2

figheight = (spacing * len(styles) + .5)
fig = plt.figure(figsize=(4 / 1.5, figheight / 1.5))
fontsize = 0.3 * 72

for i, stylename in enumerate(sorted(styles)):
fig.text(0.5, (spacing * (len(styles) - i) - 0.5) / figheight, stylename,
ha="center",
size=fontsize,
bbox=dict(boxstyle=stylename, fc="w", ec="k"))
ncol = 2
nrow = (len(styles) + 1) // ncol
axs = plt.figure(figsize=(3 * ncol, nrow)).subplots(nrow, ncol)
for ax in axs.flat:
ax.set_axis_off()
for ax, (stylename, stylecls) in zip(axs.T.flat, styles.items()):
ax.text(.5, .5,
f"{stylename}\n{inspect.signature(stylecls)}",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I'm not convinced this stylecls inspection is an improvement. This plot should primarily illustrate the available boxstyles. Adding the parameters is rather distracting. And also these are only the defaults, which should be irrelevant to most users (well maybe if you start modifying them, but that should be discussed separately.

transform=ax.transAxes, ha="center", va="center",
bbox=dict(boxstyle=stylename, fc="w", ec="k"))


###############################################################################
Expand Down
19 changes: 0 additions & 19 deletions examples/userdemo/annotate_simple01.py

This file was deleted.

4 changes: 2 additions & 2 deletions lib/matplotlib/patches.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2138,7 +2138,7 @@ def _simpleprint_styles(_styles):
{stylename: styleclass}, return a string rep of the list of keys.
Used to update the documentation.
"""
return "[{}]".format("|".join(map(" '{}' ".format, sorted(_styles))))
return "[{}]".format("|".join(map(" '{}' ".format, _styles)))


class _Style:
Expand Down Expand Up @@ -2184,7 +2184,7 @@ def pprint_styles(cls):
f'``{name}``',
# [1:-1] drops the surrounding parentheses.
str(inspect.signature(cls))[1:-1] or 'None')
for name, cls in sorted(cls._style_list.items())]]
for name, cls in cls._style_list.items()]]
# Convert to rst table.
col_len = [max(len(cell) for cell in column) for column in zip(*table)]
table_formatstr = ' '.join('=' * cl for cl in col_len)
Expand Down
Loading

Back | FazBrowse Home | New Git URL