Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

straightline.m 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. function f = straightline(value,direction,linestyle,rng)
  2. % function f = straightline(value,direction,linestyle,rng)
  3. %
  4. % <value> is a vector of values
  5. % <direction> is
  6. % 'h' or 'y' means horizontal lines
  7. % 'v' or 'x' means vertical lines
  8. % <linestyle> is like 'r:'
  9. % <rng> (optional) is [A B] with the range to restrict to.
  10. % for example, when <direction> is 'h', then <rng> being
  11. % [1 3] means to restrict the horizontal extent of the line
  12. % to between 1 and 3. if [] or not supplied, use the
  13. % full range of the current axis.
  14. %
  15. % draw lines on the current figure.
  16. % return a vector of handles.
  17. %
  18. % example:
  19. % figure;
  20. % h = straightline(randn(1,10),'v','r-');
  21. % set(h,'LineWidth',2);
  22. % input
  23. if ~exist('rng','var') || isempty(rng)
  24. rng = [];
  25. end
  26. % hold on
  27. prev = ishold;
  28. hold on;
  29. % do it
  30. ax = axis;
  31. f = zeros(1,length(value));
  32. switch direction
  33. case {'h' 'y'}
  34. if isempty(rng)
  35. rng = ax(1:2);
  36. end
  37. for p=1:length(value)
  38. f(p) = plot(rng,[value(p) value(p)],linestyle);
  39. end
  40. case {'v' 'x'}
  41. if isempty(rng)
  42. rng = ax(3:4);
  43. end
  44. for p=1:length(value)
  45. f(p) = plot([value(p) value(p)],rng,linestyle);
  46. end
  47. otherwise
  48. error('invalid <direction>');
  49. end
  50. % hold off
  51. if ~prev
  52. hold off;
  53. end