# eeglab的PLOT

[ref](https://sccn.ucsd.edu/wiki/Chapter_06:_Data_Averaging#Plotting_an_ERP_as_a_series_of_scalp_maps)

[ref2](https://sccn.ucsd.edu/wiki/Chapter_07:_Selecting_Data_Epochs_and_Comparing)

[ref3](https://sccn.ucsd.edu/wiki/Chapter_06:_Study_Statistics_and_Visualization_Options)

如果你知道了eeglab plot的逻辑，那么把数据提取出来，在matlab中做个波形图，做个频谱图，肯定没问题，可以装下X。其实eeglab中作图的函数似乎更好用，省去了什么把轴反向，设定x轴，标注baseline等一系列的麻烦事为什么不用现成的呢。。

## 波形图

### 自己的函数 （只可以看的水平）

```
Fnorm=12/(512/2)
df=designfilt('lowpassfir','FilterOrder',15,'CutoffFrequency',Fnorm)
for chan=32
% chan_label=chaninfo(chan).labels;

x=1:1126;
 x1=m101(chan,x)
 x2=m102(chan,x)
 x3=m103(chan,x)
 xx = 0:1:1125;
xx1 = filter(df,x1)
xx2= filter(df,x2)
xx3= filter(df,x3)
figure
plot(xx,xx1,'g',xx,xx2,'r',xx,xx3,'b');
hline(0,'b-')
vline(102,'b-')
 legend('green cue','red cue','blue cue')
 title(chanlocs(chan).labels)
 ylim([-10,30])
set(gca,'YDir','reverse')   
set(gca,'xtick',[0:51:1126],'xticklabel',[-200:100:2000])
end
```

![](/files/-M4Zb00Skmw3QDFtJU9H)

## eeglab 函数

### plotdata()

只能画两列，可以显示label，可以画多个条件下的波形。但是个人认为不如plottopo好用，所以没必要纠结这个函数

```
% plotdata() - plot concatenated multichannel data epochs in two-column format
%
% Usage:   >> plotdata(data)
%          >> plotdata(data,frames)
%          >> plotdata(data,frames,limits,title,channames,colors,rtitle,ydir) 
%
% Necessary input:
%   data       = data consisting of consecutive epochs of (chans,frames) 
%
% Optional inputs:
%   frames     = time frames/points per epoch {default: 0 -> data length}
%  [limits]    = [xmin xmax ymin ymax]  (x's in ms) 
%                {default|0 (or both y's 0) -> use data limits)
%  'title'     = plot title {default|0 -> none}
%  'channames' = channel location file or structure (see readlocs())
%                {default|0 -> channel numbers}
%  'colors'    = file of color codes, 3 chars per line  
%                ( '.' = space) {default|0 -> default color order}
%  'rtitle'    = right-side plot title {default|0 -> none}
%   ydir       = y-axis polarity (1 -> pos-up; -1 -> neg-up) 
%                {default|0 -> set from default YDIR in 'icadefs.m'}
```

### `plotdata(m101) %增加任何参数都要报错。。`![](/files/-M4Zb00UcwXQk0T-xSkf)

### plottopo()

可以画成地形图的形状，比较直观，可以点开看大图可以，还可以加入多个条件值得，深入研究。

```
% plottopo() - plot concatenated multichannel data epochs in a topographic
% or
%              rectangular array. Uses a channel location file with the same 
%              format as topoplot(), or else plots data on a rectangular grid. 
%              If data are all positive, they are assumed to be spectra.
% Usage:
%    >> plottopo(data, 'key1', 'val1', 'key2', 'val2')
% Or
%    >> plottopo(data,'chan_locs',frames,limits,title,channels,...
%                      axsize,colors,ydir,vert) % old function call
% Inputs:
%   data       = data consisting of consecutive epochs of (chans,frames)
%                or (chans,frames,n)
%
% Optional inputs:
%  'chanlocs'  = [struct] channel structure or file plot ERPs at channel 
%                locations. See help readlocs() for data channel format.
%  'geom'      = [rows cols] plot ERP in grid (overwrite previous option).
%                Grid size for rectangular matrix. Example: [6 4].
%  'frames'    = time frames (points) per epoch {def|0 -> data length}
%  'limits'    = [xmin xmax ymin ymax]  (x's in ms or Hz) {def|0 
%                 (or both y's 0) -> use data limits)
%  'ylim'      = [ymin ymax] y axis limits. Overwrite option above.
%  'title'     = [string] plot title {def|'' -> none}
%  'chans'     = vector of channel numbers to plot {def|0 -> all}
%  'axsize'    = [x y] axis size {default [.05 .08]}
%  'legend'    = [cell array] cell array of string for the legend. Note
%                the last element can be an integer to set legend 
%                position.
%  'showleg'   = ['on'|'off'] show or hide legend.
%  'colors'    = [cell array] cell array of plot aspect. E.g. { 'k' 'k--' }
%                for plotting the first curve in black and the second one
%                in black dashed. Can also contain additional formating.
%                { { 'k' 'linewidth' 2 } 'k--' } same as above but
%                the first line is bolded.
%  'ydir'      = [1|-1] y-axis polarity (pos-up = 1; neg-up = -1) {def -> -1}
%  'vert'      = [vector] of times (in ms or Hz) to plot vertical lines 
%                {def none}
%  'hori'      = [vector] plot horizontal line at given ordinate values.
%  'regions'   = [cell array] cell array of size nchan. Each cell contains a
%                float array of size (2,n) each column defining a time region 
%                [low high] to be highlighted.
%  'plotfunc'  = [cell] use different function for plotting data. The format
%                is { funcname arg2 arg3 arg2 ... }. arg1 is taken from the
%                data.
```

比如：

`plottopo(m101,'limits',[-200,2000,-5,5],'chanlocs',chanlocs,'ydir',-1,'hori',[0])`![](/files/-M4Zb00WRYlYFKofItFR)然而如何画多个条件，加图例，加sig区域显示呢?需要查看

pop\_comperp.m文件

line 365

timtopo(m101,chanlocs,'limits',\[-200,2000,0,0],'plotchans',\[1:32],'plottimes',\[300,600,800],'title','my plot1')


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://zh-1-peng.gitbook.io/eeg-analysis-note/plot.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
