You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to change the opacity of the polygon plots made with this package.
Here is the code I tried initially:
importbezierimportmatplotlib.pyplotaspltimportnumpyplt.clf()
nodes0=numpy.asfortranarray([[0.0, 1.0, 2.0], [0.0, -1.0, 0.0]])
edge0=bezier.Curve(nodes0, degree=2)
nodes1=numpy.asfortranarray([[2.0, 2.0], [0.0, 1.0]])
edge1=bezier.Curve(nodes1, degree=1)
nodes2=numpy.asfortranarray([[2.0, 1.0, 0.0], [1.0, 2.0, 1.0]])
edge2=bezier.Curve(nodes2, degree=2)
nodes3=numpy.asfortranarray([[0.0, 0.0], [1.0, 0.0]])
edge3=bezier.Curve(nodes3, degree=1)
curved_poly=bezier.CurvedPolygon(edge0, edge1, edge2, edge3)
# ax.set_alpha(1.0) # <-- I tried this, does not produce any effect.ax=curved_poly.plot(pts_per_edge=12) # <-- Does not take alpha argument.# plt.plot(alpha=1) # <-- I tried this, does not produce any effect.plt.show()
After posting a question StackOverflow I was able to get the Bezier polygon plots with the desired opacity using code like:
@antononcube thanks for filing! What do you think would make sense? A single alpha applied to everything? An edge alpha and a patch alpha? Returning the list of all patch / line objects created?
Well, the problem is that you have to retrieve immediately the Line2D and PathPatch objects representing the Bezier curve because if you plot multiple objects, you wouldn't know which of them belongs to your curves. I think they are prepended, i.e., Line2D[0] and PathPatch[0] would be the last curve generated. Unless, of course, you want to give all Bezier curves the same attributes; then, this approach is directly applicable. Too bad, that they don't allow passing parameters to matplotlib, return the objects, or document their source code
Again, I use the simplistic approach -- alpha is applied to all. If alpha is None, then that is the current behavior (in the bezier package.)
I am totally fine with that approach. If you would you like to send a PR I'm happy to review it and approve it. (You probably won't have to deal with unit tests if you use a keyword argument with a nice default for alpha; I think it's either 1.0 or None.) Otherwise, I'll try to get to it soon.
Worth noting also, I am currently (mostly) blocked on cutting a release due to my lack of M1 access.
I want to change the opacity of the polygon plots made with this package.
Here is the code I tried initially:
After posting a question StackOverflow I was able to get the Bezier polygon plots with the desired opacity using code like:
See "Changing the opacity of the polygons in the Python Bezier package".
The text was updated successfully, but these errors were encountered: