plotly / plotly_matlab

Plotly Graphing Library for MATLAB®
https://plot.ly/matlab/
MIT License
382 stars 167 forks source link

Add opacity on Matlab patch elements #472

Open graille opened 2 years ago

graille commented 2 years ago

NOTE: I reopened the pull request after a fail in branch selection. Old one can be deleted

Currently, patch elements don't have any opacity. So, when using a patch with an alpha layer, it just appears as a plain color. To fix this, I added a management of the alpha layer using rgba instead of rgb when it is available.

Example with a simple code using obw function (built-in function which add a patch on the frequency area containing 99% of signal energy).

close all;
figure;
nSamp = 1024;
Fs = 1024e3;
SNR = 40;
rng default

t = (0:nSamp-1)'/Fs;

x = chirp(t,50e3,nSamp/Fs,100e3);
x = x+randn(size(x))*std(x)/db2mag(SNR);
obw(x, Fs);
title('test');
grid on;

p = fig2plotly;

Before : before

After : After