This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
Disclaimer up top: this appears to be undocumented MATLAB behavior, so know that Mathworks would be able to change this behavior at any time, so old code could break if you use this.
That being said, I was trying to come up with a method to "highlight" one of the lines in my plot (kind of make it glow) as a way to make it stand out for a presentation. The only way I could find to do it using documented code was to add a patch behind the line, and set the FaceAlpha
property of that patch.
But what I found was that if you add a 4th element to the Color
property of a line, that 4th element serves as the alpha value. So, for instance if you said:
h = plot(x,y,'Color', [1,0,0,0.25], 'LineWidth', 10);
That would make a red line, 10 units wide, with an alpha value of 0.25. Or, if you wanted to change it after the fact (so in my presentation, I show the full data, and then highlight one of them in the next plot) you can use the line:
set(h, 'Color', [h.Color, 0.25], 'LineWidth', 10);
This will have it keep the same color as it was before, and then make it thicker and partially transparent.
Anyway, maybe this was already well known, but I found it really helpful for making my plots look how I wanted.
Subreddit
Post Details
- Posted
- 1 year ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/matlab/comm...