OK so is this alright?

```python
if event_id is None:
        unique_events = np.unique(events[:, 2])
    else:
        #sort list representation of event_id dictionary
        sorted_x = sorted(event_id.items(), key=lambda x: x[1])
        unique_events = list()
        for i in range(len(sorted_x)):
            c = sorted_x[i][1]
            unique_events.append(c)
```
```python
for idx, (ev, color) in enumerate(zip(unique_events, colors)):
        ev_mask = (events[:, 2] == ev)
        plt.plot((events[ev_mask, 0] - first_samp) / sfreq,
                 events[ev_mask, 2], '.', color=color, label=sorted_x[idx][0])
    plt.ylim([min_event - 1, max_event + 1])
    plt.xlabel('Time (s)')
    plt.ylabel('Events id')
    plt.grid('on')
    if event_id is not None:
        plt.legend()
```