|
71 | 71 | obj.PlotlyDefaults.ErrorbarWidth = 6;
|
72 | 72 | obj.PlotlyDefaults.ShowBaselineLegend = false;
|
73 | 73 | obj.PlotlyDefaults.Bargap = 0;
|
| 74 | + obj.PlotlyDefaults.CaptionMarginIncreaseFactor = 1.2; |
| 75 | + obj.PlotlyDefaults.MinCaptionMargin = 80; |
74 | 76 |
|
75 | 77 | %-State-%
|
76 | 78 | obj.State.Figure = [];
|
@@ -347,6 +349,40 @@ function validate(obj)
|
347 | 349 | end
|
348 | 350 | end
|
349 | 351 |
|
| 352 | + %----ADD A CUSTOM CAPTION-----% |
| 353 | + function obj = add_caption(obj, caption_string, varargin) |
| 354 | + |
| 355 | + caption.text = caption_string; |
| 356 | + |
| 357 | + % defaults |
| 358 | + caption.xref = 'paper'; |
| 359 | + caption.yref = 'paper'; |
| 360 | + caption.xanchor = 'left'; |
| 361 | + caption.yanchor = 'top'; |
| 362 | + caption.x = 0.1; |
| 363 | + caption.y = -0.05; |
| 364 | + caption.showarrow = false; |
| 365 | + |
| 366 | + % inject any custom annotation specs |
| 367 | + for n = 1:2:length(varargin) |
| 368 | + caption = setfield(caption, varargin{n}, varargin{n+1}); |
| 369 | + end |
| 370 | + |
| 371 | + % adjust the bottom margin |
| 372 | + obj.layout.margin.b = max(obj.layout.margin.b, ... |
| 373 | + obj.PlotlyDefaults.MinCaptionMargin); |
| 374 | + |
| 375 | + % add the new caption to the figure |
| 376 | + obj.State.Figure.NumTexts = obj.State.Figure.NumTexts + 1; |
| 377 | + obj.layout.annotations{obj.State.Figure.NumTexts} = caption; |
| 378 | + |
| 379 | + % update the figure state |
| 380 | + obj.State.Text(obj.State.Figure.NumTexts).Handle = NaN; |
| 381 | + obj.State.Text(obj.State.Figure.NumTexts).AssociatedAxis = gca; |
| 382 | + obj.State.Text(obj.State.Figure.NumTexts).Title = false; |
| 383 | + |
| 384 | + end |
| 385 | + |
350 | 386 |
|
351 | 387 | %------------------------REST API CALL----------------------------%
|
352 | 388 |
|
|
0 commit comments