Back to the main page.

Bug 3192 - Colorspecification for ft_plot_mesh does not allow spelled out colors

Status CLOSED FIXED
Reported 2016-10-25 17:08:00 +0200
Modified 2017-01-17 11:29:45 +0100
Product: FieldTrip
Component: plotting
Version: unspecified
Hardware: PC
Operating System: Windows
Importance: P5 normal
Assigned to: Robert Oostenveld
URL:
Tags:
Depends on:
Blocks:
See also:

Jens Klinzing - 2016-10-25 17:08:19 +0200

The ft_plot_mesh documentation allows the specification of vertex color by RGB code [0 23 42], one-letter colors 'r', or spelled-out color names 'red'. However, the latter leads to an error. Character input for vertexcolor is only allowed by the code if it is either exactly one character or has exactly as many characters as there are vertices (to allow color specification for each vertex separately). Multiple-letter color definitions lead to: 'Unknown color specification for the vertices' One could allow all numbers of characters but then in the unlikely case of having as many vertices as the color name has letters one would have to check whether 'red' means color 'r', 'e', and 'd' for each vertex respectively or if the user intended one color for all vertices. I guess the simplest solution would be not to allow for multiple-letter color definitions in ft_plot_mesh (and upstream plotting functions like ft_plot_vol). Special cases like 'brain' are translated into RGB codes early in the function so they work as intended. Example code: cfg = []; cfg.grid.xgrid = -20:5:20; cfg.grid.ygrid = -20:5:20; cfg.grid.zgrid = -20:5:20; grid = ft_prepare_sourcemodel(cfg); figure, ft_plot_mesh(grid, 'vertexcolor', 'red')


Robert Oostenveld - 2016-10-25 23:08:44 +0200

The special colors are coded in functions, e.g. plotting/private/red.m We could check whether the user specified string is a function, and if so call that function. Otherwise just pass it on to matlab. This probably not only applies to ft_plot_mesh, but also other plotting functions. @Jens, could you do a proposal for a change on github?


Jens Klinzing - 2016-10-26 12:03:25 +0200

This would be one way to do it: https://github.com/fieldtrip/fieldtrip/pull/241


Jens Klinzing - 2016-10-28 17:09:07 +0200

In line with your remarks on my first proposal I sent another pull request, this time with changes in all affected plotting functions I could find. https://github.com/fieldtrip/fieldtrip/pull/248


Robert Oostenveld - 2016-11-02 17:30:52 +0100

I merged https://github.com/fieldtrip/fieldtrip/pull/248 and followed up with my own PR containing the test script as https://github.com/fieldtrip/fieldtrip/pull/252. thanks Robert


Robert Oostenveld - 2017-01-17 11:29:45 +0100

closed multiple bugs that were resolved some time ago