File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020import matplotlib .patches as patches
2121import matplotlib .path as path
2222
23- fig , axs = plt .subplots (2 )
23+ fig , axs = plt .subplots (1 )
2424
2525np .random .seed (19680801 ) # Fixing random state for reproducibility
2626
4444# make a patch out of it, don't add a margin at y=0
4545patch = patches .PathPatch (barpath )
4646patch .sticky_edges .y [:] = [0 ]
47- axs [0 ].add_patch (patch )
48- axs [0 ].autoscale_view ()
47+ axs .add_patch (patch )
48+ axs .autoscale_view ()
49+ plt .show ()
4950
5051# %%
5152# Instead of creating a three-dimensional array and using
5253# `~.path.Path.make_compound_path_from_polys`, we could as well create the
5354# compound path directly using vertices and codes as shown below
5455
56+ fig , axs = plt .subplots (1 )
5557nrects = len (left )
5658nverts = nrects * (1 + 3 + 1 )
5759verts = np .zeros ((nverts , 2 ))
7274# make a patch out of it, don't add a margin at y=0
7375patch = patches .PathPatch (barpath )
7476patch .sticky_edges .y [:] = [0 ]
75- axs [1 ].add_patch (patch )
76- axs [1 ].autoscale_view ()
77-
77+ axs .add_patch (patch )
78+ axs .autoscale_view ()
7879plt .show ()
7980
8081# %%
You can’t perform that action at this time.
0 commit comments