Filtering Artists in a View

matplotview.view() supports filtering out artist instances and types using the filter_set parameter, which accepts an iterable of artists types and instances.

Original Plot, View Filtering Out Circles, View Filtering Out Just the Text Artist.
 8 import matplotlib.pyplot as plt
 9 from matplotview import view
10
11 fig, (ax1, ax2, ax3) = plt.subplots(3, 1)
12
13 # Plot a line, circle patch, and some text in axes 1
14 ax1.set_title("Original Plot")
15 ax1.plot([(i / 10) for i in range(10)], [(i / 10) for i in range(10)], "r")
16 ax1.add_patch(plt.Circle((0.5, 0.5), 0.25, ec="black", fc="blue"))
17 text = ax1.text(0.2, 0.2, "Hello World!", size=12)
18
19 # Axes 2 is viewing axes 1, but filtering circles...
20 ax2.set_title("View Filtering Out Circles")
21 view(ax2, ax1, filter_set=[plt.Circle])  # We can pass artist types
22 ax2.set_xlim(ax1.get_xlim())
23 ax2.set_ylim(ax1.get_ylim())
24
25 # Axes 3 is viewing axes 1, but filtering the text artist
26 ax3.set_title("View Filtering Out Just the Text Artist.")
27 view(ax3, ax1, filter_set=[text])  # We can also pass artist instances...
28 ax3.set_xlim(ax1.get_xlim())
29 ax3.set_ylim(ax1.get_ylim())
30
31 fig.tight_layout()
32 fig.show()

Total running time of the script: (0 minutes 0.392 seconds)

Gallery generated by Sphinx-Gallery