Apr-11-2020, 05:59 PM
Hi there, first post here.
I'm trying to dig deeper into matplotlib and learn how it works under the cover. So I thought it'd be a simple task to draw a few points on the canvas and connect them with some lines. I was wrong. I looked at the source code for Axes.scatter. So I wrote the following code:
Can anyone tell me how I can achieve my goal? Sorry if this is the wrong forum; it seems matplotlib is mostly used for data-science.
I'm trying to dig deeper into matplotlib and learn how it works under the cover. So I thought it'd be a simple task to draw a few points on the canvas and connect them with some lines. I was wrong. I looked at the source code for Axes.scatter. So I wrote the following code:
fig = plt.figure() ax = fig.add_axes((0,0,1,1), frameon = True, xlim = (0,1), ylim = (0,1), xticks=[0.2], yticks=[0.2]) pos = [(0.2, 0.2), (0.2, 0.3), (0.3, 0.4), (0.4, 0.4), (0.5, 0.3), (0.5, 0.2), (0.35, 0.1)] pp = Polygon([(0,0), (0.02, 0.02), (0.04, 0)]) #mypath = pp.get_path() mypath = pp.get_path().transformed(pp.get_transform()) #* dots = collections.PathCollection(paths = (mypath,), offsets= pos) #dots.set_transform(transforms.IdentityTransform()). #** ax.add_collection(dots) plt.show()I expected that this would render 5 triangles in my canvas. But this only drew 1 triangle at the bottom left corner of the canvas. Substituting the line marked with * with the line above it doesn't change anything. Adding line marked with ** causes the single triangle to vanish too.
Can anyone tell me how I can achieve my goal? Sorry if this is the wrong forum; it seems matplotlib is mostly used for data-science.