Add alpha capability to "Line" class
Emma Farnan
on 16 Nov 2023
Latest activity Reply by Emma Farnan
on 28 Nov 2023
I think it would be a really great feature to be able to add an Alpha property to the basic "Line" class in MATLAB plots. I know that I have previously had to resort to using Patch to be able to plot semitransparent lines, but there are also so many other functions that rely on the "Line" class.
For example, if you want to make a scatter plot from a table with things specified into groups, you can use ScatterHistogram or gscatter but since gscatter uses the Line class, you can't adjust the marker transparency. So if you don't want the histograms, you are stuck with manually separating it and using scatter with hold on.
7 Comments
A poorly documented point is that "chart line" objects accept RGBA color specifications. For example,
plot(rand(1,20),'Color', [.9 .3 .5 .2])
plots a line with an alpha value of 0.2
However... if for any reason the element is saved, then the saved version will not store the alpha component. In particular, savefig() will not store the alpha component; and if you try to do graphics in a parallel worker and send the graphics back, then what is received will (probably) not have the alpha component.
Thanks for sharing your idea here!