我正在嘗試在 ERP 資料的 MATLAB 中創建一個繪圖。目前,下面的代碼為通道 1 繪制了 26 個參與者的波形,Y 軸上的平均幅度和 X 上的時間。我想改變繪圖,使波形都是淺灰色,但在有很多的地方變暗一波又一波。
times = Condition1.time;
channel = [1];
% the difference (for every participant, every channel, and every timepoint)
diff = (grandaverages.Condition1.individual) - (grandaverages.Condition2.individual);
channeldiffwaves = squeeze( mean( diff(:,channels,:), 2 ) );
% make the space to put the figure on
figure; hold on;
% list of participants to plot
plotparticipantIdx = [1:26];
% go through each participant
for participantIdx = plotparticipantIdx
ptpdiffwave = channeldiffwaves( participantIdx, : );
plot( times, ptpdiffwave )
end
% make a x-axis at zero
plot( times, zeros( size(times) ), 'k' )
我怎樣才能使所有線條變淺灰色并在線條重疊的地方變暗?
uj5u.com熱心網友回復:
您可以使用 RGB-alpha 四聯體:
plot(x, y, 'Color', [0 0 0 0.3]);
前三個條目是您的標準 RGB 三元組,即0 0 0
黑色,然后在 0(不可見)和 1(完全可見)之間更改 alpha(=透明度)。
作為旁注,這甚至沒有記錄在 MATLAB 檔案的圖表線外觀和行為部分中。
我不太清楚何時引入了這種語法。在我的 R2007b 上它不起作用,但從 2017 年開始,這個解決方案開始在互聯網上出現,因此我認為這是在 R2016b 中對圖形引擎進行大修時引入的。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/493243.html
下一篇:從向量中的數字塊創建矩陣