Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt at fixing figure name in ft_sourceplot #2167

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

britta-wstnr
Copy link
Contributor

As mentioned in #2166 cfg.figurename in ft_sourceplot gets ignored as it gets set regardless of the presence of this field.
This fixes it - but might be a bit sloppy as cfg.figurename does get passed to open_figure in the code above my fix - was not sure if it should rather get fixed there?

CC @robertoostenveld

@robertoostenveld
Copy link
Contributor

would it not be better to have the figure title always handled by open_figure ?

Right now it appears from the ft_sourceplot code that - as an afterthought - someone added the lines at the end of the function that, based on dataname, update the figure title.

@britta-wstnr
Copy link
Contributor Author

Indeed, hence why I said this is a "sloppy" fix - that just fixes it exactly where the problem occurs right now

@robertoostenveld
Copy link
Contributor

cfg.figurename and cfg.dataname seem two options that aim at solving the same thing. It would be better to merge the functionality.

@robertoostenveld
Copy link
Contributor

robertoostenveld commented Jan 19, 2023

this is a pointer in the direction of a fix ad58d6f

I see the following options:

  1. the user fully specifies cfg.figurename
  2. the user does not specify the full name, but the function name (using mfilename) is used AND
    a. part of the name is specified by the user in cfg.dataname
    a. part of the name comes from cfg.inputfile
    c. part of the name comes from the input variable names using inputname

Whether a, b, c, should be optional or always used, I don't know

@robertoostenveld
Copy link
Contributor

@britta-wstnr

just for your ft_sourceplot case: if you do this

% construct the figure title
if isempty(cfg.figurename)
  if isfield(cfg, 'dataname') && ~isempty(cfg.dataname)
    cfg.figurename = sprintf('%d: %s: %s', double(gcf), mfilename, join_str(', ', cfg.dataname));
  elseif isfield(cfg, 'inputfile') && ~isempty(cfg.inputfile)
    cfg.figurename = sprintf('%d: %s: %s', double(gcf), mfilename, join_str(', ', cfg.inputfile));
  elseif nargin>1
    cfg.figurename = sprintf('%d: %s: %s', double(gcf), mfilename, join_str(', ', arrayfun(@inputname, 2:nargin, 'UniformOutput', false)));
  else
    cfg.figurename = sprintf('%d: %s', double(gcf), mfilename);
  end
end

just prior to open_figure, does that work and address your issue?

Btw, this is me typing some code without trying it out. I am not sure about the set(gcf, 'NumberTitle', 'off'), should that not be inside open_figure and always apply?

@robertoostenveld
Copy link
Contributor

Hi @britta-wstnr, have you tried the code suggestion I gave above?

@britta-wstnr
Copy link
Contributor Author

Hi @robertoostenveld no, I have not had the time yet to look at it again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants