-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfigPW.m
1529 lines (1359 loc) · 52.2 KB
/
figPW.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
function figPW(varargin)% FigType, ext, katalog)
% Saves current figure, main part of figLib.
% Central part of 3 functions: figP, figPW and figPSW. Use the last one to save many figures.
%
% Usage:
% figPW("copy", 1) % Figure will be copied to clipboard
% figPW copy % short version, with auto setting parameters
% or just (fast version) save current figure to file with timestamp in filename
% figPW
%
% Function gets pair of arguments. (as "copy" above), if not specified
% second argument enable or disable functionality
%
% Example params (true or false, second pair param):
% copy - get your figure without margin, into clipboard and past into your document,
% maxF - maximize current figure before saving,
% exportPdf - export wector graphics figure to PDF file (main option of lib),
% openFolder - open exported file directory,
% argOpenFile - open file in system default program,
% tileSpacing - if is posible apply of this: "loose" (default) | "compact" | "tight" | "none"
% tilePadding - "none" (default) | "loose" | "compact" | "tight"
% overwrite - delete file before exportig, to avoid permission confilct on Windows
% timestamp - add date and time to exported filename
% hqPNG - export high quality png file,
% axis - add param for axis, eg. figPW("axis", "tight"),
% hLegend - horizontal legend,
% Interpreter - eg. figPW("Interpreter", "latex")
% styleLudwin - predefined figure style, to enable (1) | (0) to disable
% stylePiotr - predefined figure style, to enable (1) | (0) to disable
% noMargin - deprecated, replaced by "copy" or "exportPDF"
% TNR - automatic Times New Roman font changing
% saveCopyFig - defalut = true (backup file)
% argSkipSaveAs - doesn't save default file, default = false
% nrF - just select figure you want to save
% vectorReplacedByTIFFigBytes - size of figure, default = 50 000,
% only for export fig argument
% scale - set the scalar, default = 1
% valScaleX - scale horizontally
% valScaleY - scale vertically
% fileName - set output files before extension text
% styleGrid - add grid scale
% font - Familly fontName (eg. "Verdana")
% plotContur - black contur (true)
% goldenRatio - default = 1, if none zero, use as floating point scalar
% pixels, if negative scalar value use as 3.25 inch article column size
%
% Example optioal params with value
% path - specyfy output file prefix of folder (with slash at end) path
% ext - extension for files
%
% Args are compared case insensitive
%
% Example 1: % for PhD students
% figPW("exportPdf", 1, "openFolder", 1, "TNR", 0, "styleLudwin", 1, "overwrite", 1)
%
% Example 2:
% figPW("path", exportPath, "exportPDF", 1,"openFolder",1,"saveCopyFig", ...
% backup,"skipSaveAs",1, "scale", mnoznik);
% Example 3:
% figPW art
% TODO
% h = figure(1); h.Position = [1 1 1000*1.618033 1000 ];
% overlafGithubLimit = 50 MB for files
% schowek do pdfa no margin
% size legend
% open filo
% instal ghostscript link
% if file exist timestamp add
% "figPW(ext = 'png', FigType = 0 do 4, katalog = 'figury/')",...
%0 fast
% overwrite flag
% "figPW('svg', 4, 'figury/')"); -2 dbstack? if figPSW
% if( nargin==1 && length(dbstack(1)) == 0 ) % if only one param & not runed from console
% fprintf('%s\n%s\n',...
% "figPW(ext = 'png', FigType = 0 do 4, katalog = 'figury/')",...
% "figPW('svg', 4, 'figury/')");
% end
% parse multiple arg
% arguments (Repeating)
% varargin string
% end
% set(0,'DefaultAxesFontName','CMU Serif Roman')
if nargin == 1
% inName = inputname(1) % not working
while 1 % used to skip section of code statement by break; keyword
if(isnumeric( varargin{1} ))
FigType = varargin{1}; % change to fig nr
elseif(isText( varargin{1} ))
if( strcmpi(varargin{1}, "art") || strcmpi(varargin{1}, '"art"') ) % set default for article arguments
c=1;
varargin{c} = "exportPDF"; c=c+1; varargin{c} = 1; c=c+1;
% varargin{c} = "maxF"; c=c+1; varargin{c} = 1; c=c+1;
% varargin{c} = "goldenRatio";c=c+1; varargin{c} = -2; c=c+1;
varargin{c} = "openFolder"; c=c+1; varargin{c} = 1; c=c+1;
varargin{c} = "skipSaveAs"; c=c+1; varargin{c} = 1; c=c+1;
varargin{c} = "vectorReplacedByTIFFigBytes"; c=c+1; varargin{c} = 2^30; c=c+1;
% varargin{5} = "stylePiotr"; varargin{6} = 1;
% varargin{c} = "maxF"; c=c+1; varargin{c} = 1; c=c+1;
% nargin = numel(varargin)
% varargin{1} = "maxoveleaf50";
elseif( strcmpi(varargin{1}, "hq") || strcmpi(varargin{1}, '"hq"') ) % set default for article arguments
c=1;
varargin{c} = "hqpng"; c=c+1; varargin{c} = 1; c=c+1;
varargin{c} = "openFolder"; c=c+1; varargin{c} = 1; c=c+1;
varargin{c} = "goldenRatio";c=c+1; varargin{c} = 0; c=c+1;
varargin{c} = "saveCopyFig";c=c+1; varargin{c} = 0; c=c+1;
varargin{c} = "skipSaveAs"; c=c+1; varargin{c} = 1; c=c+1;
varargin{c} = "tileSpacing"; c=c+1; varargin{c} = "tight"; c=c+1;
varargin{c} = "tilePadding"; c=c+1; varargin{c} = "none"; c=c+1; % none ?
% (convertIfOldTypeFig, 1)
elseif( strcmpi(varargin{1}, "copy") || strcmpi(varargin{1}, '"copy"') ) % set default for article arguments
c=1; varargin{c} = "copy"; c=c+1; varargin{c} = 1; c=c+1;
else
% unmached = 1
break;
end
fprintf(1, " figPW("); comma = ', '; c = c-1;
for( i = 1:2:c )
if(c-i < 2) comma = ''; end
secParam = string(varargin{i+1});
if(isstring(varargin{i+1})) secParam = strcat( "'", string(varargin{i+1}), "'"); end
fprintf(1, "'%s', %s%s", varargin{i}, secParam, comma );
end
fprintf(1, ") %% shorted param setup explanation \n");
else
varargin{1}
end
break % prevents infinite loop
end % while 1
end
% Arguments default values
valSaveTo = "fig/";
valDefaultExt = "png";
valNoTNR = "true";
valInterpreter = 'tex';
valOpenFolder = false;
valOpenFile = false;
valExportPdf = false;
valStyleLudwin = false;
valStylePiotr = false;
valOverwrite = false;
valTimestamp = false;
valSaveCopyFig = true;
valSkipSaveAs = false;
valNrF = 1;
valVectorReplacedByTIFFigBytes = 5e4;
valScale = 1;
valScaleX = 1;
valScaleY = 1;
valFileName = "";
valStyleGrid = false;
valFont = "Helvetica";
valPlotContur = true;
valGoldenRatio = 1; % scaling factor
valTilePadding = 'none';
% valueAxis = "";
% valNoMarginPDF = "";
%arguments names
argCopy = "copy";
argMaxF = "maxF";
argNoMargin = "noMargin";
argHighQualityPNG = "hqPNG";
argAxis = "axis";
argHorizontalLegend ="hLegend";
argInterpreter = "Interpreter";
% argNoMarginPDF = "noMarginPDF";
argOpenFolder = "openFolder";
argOpenFile = "openFile";
argExportPdf = "exportPdf";
argOverwrite = "overwrite";
argStyleLudwin = "styleLudwin";
argStylePiotr = "stylePiotr";
argTimestamp = "timestamp";
argTileSpacing = "tileSpacing";
argSaveCopyFig = "saveCopyFig";
argSkipSaveAs = "skipSaveAs";
argNrF = "nrF";
argVectorReplacedByTIFFigBytes = "vectorReplacedByTIFFigBytes";
argScale = "scale";
argScaleX = "scaleX";
argScaleY = "scaleY";
argFileName = "fileName";
argStyleGrid = "styleGrid";
argFont = "font";
argPlotContur = "plotContur";
argGoldenRatio = "goldenRatio";
argTilePadding = "tilePadding";
argRePositonYlabel = "rePositonYlabel";
% -- Parser ---------------------------------------------------------------
p = inputParser; p.FunctionName = mfilename('name');
% p.KeepUnmatched = 1; % dont stop if param not maching
% p.PartialMatching = 1;
% p.StructExpand = 1;
% with default values
addOptional(p, 'ext', valDefaultExt);
addOptional(p, 'path', valSaveTo);
addOptional(p, 'TNR', valNoTNR);
addOptional(p, argInterpreter, valInterpreter);
addOptional(p, argOpenFolder, valOpenFolder);
addOptional(p, argOpenFile, valOpenFile);
addOptional(p, argExportPdf, valExportPdf);
addOptional(p, argOverwrite, valOverwrite);
addOptional(p, argStyleLudwin, valStyleLudwin);
addOptional(p, argStylePiotr, valStylePiotr);
addOptional(p, argTimestamp, valTimestamp);
addOptional(p, argSaveCopyFig, valSaveCopyFig);
addOptional(p, argSkipSaveAs, valSkipSaveAs);
addOptional(p, argVectorReplacedByTIFFigBytes, valVectorReplacedByTIFFigBytes);
addOptional(p, argFileName, valFileName);
addOptional(p, argStyleGrid, valStyleGrid);
addOptional(p, argFont, valFont);
addOptional(p, argPlotContur, valPlotContur);
addOptional(p, argGoldenRatio, valGoldenRatio);
addOptional(p, argTilePadding, valTilePadding);
% without default value
optParam = [ argCopy, "TZ1", "TZ2", argNoMargin, argMaxF, argHighQualityPNG, ...
argAxis, argHorizontalLegend, argTileSpacing, argNrF, argScale, argScaleX, argScaleY, argRePositonYlabel];
for i = 1:length(optParam)
addOptional(p,optParam(i),[]);
end
parse(p, varargin{:});
% -- Get values from parser -----------------------------------------------
ext = p.Results.ext;
tmp = char(ext);
if(tmp(1) ~= '.') ext = strcat('.', ext); end
katalog = p.Results.path;
if isstring(p.Results.TNR) TNR = str2num( p.Results.TNR ); else TNR = p.Results.TNR; end
if isstring(p.Results.copy ) valArgCopy = str2num( p.Results.copy ); else valArgCopy = p.Results.copy; end
valueAxis = p.Results.axis;
variantHorizontalLegend = p.Results.hLegend;
valInterpreter = p.Results.Interpreter;
valOpenFolder = p.Results.openFolder;
valOpenFile = p.Results.openFile;
valExportPdf = p.Results.exportPdf;
valOverwrite = p.Results.overwrite;
valStyleLudwin = p.Results.styleLudwin;
valStylePiotr = p.Results.stylePiotr;
% valMaxF = p.Results.valMaxF; todo
valTimestamp = p.Results.timestamp;
valTileSpacing = p.Results.tileSpacing;
valSaveCopyFig = p.Results.saveCopyFig;
valSkipSaveAs = p.Results.skipSaveAs;
valNrF = p.Results.nrF;
valVectorReplacedByTIFFigBytes = p.Results.vectorReplacedByTIFFigBytes;
valScale = p.Results.scale;
valScaleX = p.Results.scaleX;
valScaleY = p.Results.scaleY;
valFileName = string(p.Results.fileName);
valStyleGrid = p.Results.styleGrid;
valFont = p.Results.font;
valPlotContur = p.Results.plotContur;
valGoldenRatio = p.Results.goldenRatio;
valTilePadding = p.Results.tilePadding;
valRePositonYlabel = p.Results.rePositonYlabel;
if(~isempty(valNrF))
figure(valNrF)
end
if(nargin<2) ext = 'png'; end;
% if(nargin<3) katalog = 'figury/'; end;
if ~exist(katalog, 'dir') mkdir (katalog); end;
%%%%%%%% Generate filename %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fTitle = ''; % do zapisywanej nazwy pliku
h1=get(gca,'title');
handle = gcf;
tmp = handle.Children;
SGtitle = '';
try
for i = 1:length(tmp)
tmp = handle.Children(i);
if(strcmp(get(tmp, 'type'), 'subplottext') == 1 )
SGtitle = tmp.String;
end
if(strcmp(get(tmp, 'Type'), 'tiledlayout') == 1 )
SGtitle = tmp.Title.String;
end
end
catch
disp('Error getting sgtitle')
end
tsAdded = false;
if( isempty(SGtitle) )
title=get(h1,'string');
if( isempty(title) )
if(nargin<=1)
fTitle = [ datestr(now ,'yyyy-mm-dd_HH.MM.ss') '_'];
tsAdded = true;
else
end
else
fTitle = strcat(title, "_");
end
else
% tmp = tmp.String;
fTitle = strcat(string(SGtitle), "_");
end
nrName = get( get(gcf,'Number'), 'Name' );
if(valTimestamp)
if(~tsAdded) fTitle = [ datestr(now ,'yyyy-mm-dd_HH.MM.ss') '_']; end
end
% title([{'Dziedzina czasu'},{'Cha-ka skokowa'}]);
% xlabel('O rzeczywista'); ylabel('O urojona');
% legend(str{:});
[calling_mfile, index] = dbstack(0);
mcName = [calling_mfile(length(calling_mfile)).name '_'];
[path, filename, Fext] = fileparts( mfilename('.')); [~, folderName] = fileparts(pwd());
filename = strcat(mcName, fTitle, nrName, num2str(get(gcf,'Number')));
filename = regexprep(filename, {'[%()*:\\" / ]+', '_+$'}, {'_', ''});
folderName = regexprep(folderName, {'[%()*:\\" / ]+', '_+$'}, {'_', ''});
if(size(filename,1) > 1) filename = filename(1);end;
if(strlength(valFileName) == 0)
folderName = strcat(katalog, folderName, "_");%if(nargin == 1) folderName = katalog; nrName=''; end; % nazwa TEGO *.m-pliku
folderFilename = strcat(folderName,filename);
else
folderFilename = strcat(katalog,string(valFileName));
end
filenameExt = strcat(folderFilename, ext); % Default filename
%%%%%%% Fast save %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if numel(varargin) == 0
figP(folderFilename, ext, TNR, valArgCopy, valOpenFolder, valOpenFile, valExportPdf, valOverwrite, valSkipSaveAs)
return
end
%%%%%%% Save copy %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
h=gcf; % for saveas()
% set(h,'PaperOrientation','Landscape');
%set(h,'Units','centimeters');
%set(h,'OuterPosition',[1, 1, 29 21]);
% set(h,'Position',2*get(h,'Position'));
% fn = nextname(filename, int2str(nrKol), "") to do
defaultExtension = '.fig';
if(valSaveCopyFig)
if( strcmpi(ext, defaultExtension) == 0 ) % case insensitive
if(defaultExtension(1) ~= '.') defaultExtension = strcat('.', defaultExtension); end
fileNameExt = strcat(folderFilename, defaultExtension);
if(valOverwrite)
if(exist(fileNameExt, 'file'))
delete(fileNameExt);
end
end
saveas(h, fileNameExt);
fprintf(1, '\t* Zapisano kopię: "%s%s"\n', folderFilename, defaultExtension);
end
end
% zapiszFig(nrPliku, nrKol, 'fig');
% zapiszFig(nrPliku, nrKol, 'pdf');
% zapiszFig(nrPliku, nrKol, 'emf'); %!
% zapiszFig(nrPliku, nrKol, 'eps');
% zapiszFig(nrPliku, nrKol, 'tif');
% zapiszFig(nrPliku, nrKol, 'pcx');
% zapiszFig(nrPliku, nrKol, 'jpg');
% zapiszFig(nrPliku, nrKol, 'pbm');
% zapiszFig(nrPliku, nrKol, 'pgm');
% zapiszFig(nrPliku, nrKol, 'png');
% zapiszFig(nrPliku, nrKol, 'ppm');
%%%%%%% Font Times New Roman %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if ( TNR )
font = "Times";
if(strlength(valFont)>0)
font = "Verdana";
font = valFont;
end
childs = get( gcf, 'Children' );
for(childAxInx = 1:length(childs) )
ca = childs(childAxInx);
FontSizeTitle = 12;
FontSizeLabels = 10;
FontSizeTicks = 8;
FontSizeLegend = 8;
sgTitleFontSize = 15;
type = get( ca, 'type' );
if( 1 == strcmp( type, 'subplottext' ))
set(ca,...
'FontName',font,...
'FontUnits','points',...
'FontSize',sgTitleFontSize);% 'FontWeight','normal',...
continue
end
if( 1 == strcmp( type, 'colorbar' ))
set(ca,...
'FontName',font,...
'FontWeight','normal',...
'FontSize',FontSizeTicks);
type = get( ca, 'type' );
continue
end
if( 1 == strcmp( type, 'tiledlayout' ))
% continue
% set(ca,...
% 'FontName',font,...
% 'FontUnits','points',...
% 'FontWeight','normal',...
% 'FontSize',FontSizeTicks);
type = get( ca, 'type' );
if(get(ca.XLabel,'Interpreter') ~= "latex" )
set(get(ca,'XLabel'), ...
'FontWeight','normal',...
'FontSize',FontSizeLabels,...
'Interpreter',valInterpreter,...
'FontName',font);
end
set(get(ca,'YLabel'),...
'FontWeight','normal',...
'FontSize',FontSizeLabels,...
'Interpreter',valInterpreter,...
'FontName',font);
set(get(ca,'Title'),...
'FontWeight','normal',...
'FontSize',FontSizeTitle,...
'Interpreter',valInterpreter,...
'FontName',font);
set(get(ca,'Subtitle'),...
'FontSize',FontSizeLegend,...
'Interpreter',valInterpreter,...
'FontName',font);
if(isfield(ca, "Legend"))
set(get(ca,'Legend'),...
'FontUnits','points',...
'FontSize',FontSizeLegend,...
'Interpreter',valInterpreter,...
'Location','NorthEast',...
'FontName',font);
end
continue
end
set(ca,...
'FontName',font,...
'FontUnits','points',...
'FontWeight','normal',...
'FontSize',FontSizeTicks);
type = get( ca, 'type' );
if( 1 == strcmp( type, 'legend' ))
continue;
end
if(get(ca.XLabel,'Interpreter') ~= "latex" )
set(get(ca,'Xlabel'), ...
'FontUnits','points',...
'FontSize',FontSizeLabels,...
'Interpreter',valInterpreter,...
'FontName',font);%'FontWeight','normal',...
end
set(get(ca,'Ylabel'),...
'FontUnits','points',...
'FontWeight','normal',...
'FontSize',FontSizeLabels,...
'Interpreter',valInterpreter,...
'FontName',font);
set(get(ca,'Title'),...
'FontUnits','points',...
'FontWeight','normal',...
'FontSize',FontSizeTitle,...
'Interpreter',valInterpreter,...
'FontName',font);
set(get(ca,'Legend'),...
'FontUnits','points',...
'FontSize',FontSizeLegend,...
'Interpreter',valInterpreter,... % 'Location','NorthEast',...
'FontName',font);
end
end
%%%%%%% Axis %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if (~ismember(argAxis, p.UsingDefaults))
childs = get( gcf, 'Children' );
for(childAxInx = 1:length(childs) )
ca = childs(childAxInx);
type = get( ca, 'type' );
if type ~= "axes"
continue
end
xlim(ca, valueAxis)
ylim(ca, valueAxis)
% set(ca, "axes", valueAxis); % not work because field is readOnly
end
end
%%%%%%% Style %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if(valPlotContur)
childs = get( gcf, 'Children' );
for(childAxInx = 1:length(childs) ) % for old type plots
ca = childs(childAxInx);
type = get( ca, 'type' );
if( 1 == strcmp( type, 'axes' ))
set(ca,'Box','on');
end
end
end
if (~ismember(argStyleLudwin, p.UsingDefaults))
if (valStyleLudwin)
allHyl = []; % ylabel pos matrix
set(groot,'defaultAxesTickLabelInterpreter','latex');
% arrayfun(@(x) grid(x,'on'), findobj(gcf,'Type','axes'))
% arrayfun(@(x) grid(x,'minor'), findobj(gcf,'Type','axes'))
% grid minor
childs = get( gcf, 'Children' );
skipYlabelPos = 1;
if(isfield(childs,"GridSize"))
if(childs.GridSize(2)>1)
% TODO
else skipYlabelPos = 0; %no problemo
end
else fprintf(1,"Old styled figure, ylabel positioning skipped, use 'figConvert'\n");
end
for(childAxInx = 1:length(childs) )
ca = childs(childAxInx);
FontSizeTitle = 12;
FontSizeLabels = 10;
FontSizeTicks = 8;
FontSizeLegend = 8;
sgTitleFontSize = 15;
font = valFont;
type = get( ca, 'type' );
if( 1 == strcmp( type, 'axes' ))
set(ca,'FontSize',11);
h=get(ca,'xlabel');
% set(h, 'FontSize', 11)
set(h,'Interpreter','latex');
h=get(ca,'ylabel');
% set(h, 'FontSize', 11)
set(h,'Interpreter','latex');
h=get(ca,'zlabel');
% set(h, 'FontSize', 11)
set(h,'Interpreter','latex');
%todo Z label
continue
end
% set(ca,...
% 'FontName',font,...
% 'FontUnits','points',...
% 'FontWeight','normal',...
% 'FontSize',FontSizeTicks);
% type = get( ca, 'type' );
% set(findobj(gcf,'type','axes'),'FontName','Calibri','FontSize',11, ...
% 'FontWeight','Bold', 'LineWidth', 1,'layer','top');grid on
if( 1 == strcmp( type, 'legend' ))
continue;
end
if( 1 == strcmp( type, 'tiledlayout' ))
gcaP = gca().Parent;
ch = gcaP.Children;
set(ca.Title,...
'FontName',font,...
'FontWeight','normal',...
'FontSize',sgTitleFontSize);
% nums = tilenum(flipud(gca))
for( i = 1:numel(ch))
a = ch(i);
atype = get( a, 'type' );
if( 1 == strcmp( atype, 'legend' ))
h = a;
set(h,'Interpreter','latex');
set(h,'FontName',font);
set(h,'FontSize',FontSizeLegend);
continue
end
set(a,'FontSize', FontSizeLabels);
h=get(a,'XLabel');
set(h,'Interpreter','latex');
set(h,'FontName',font);
set(h,'FontSize',FontSizeLabels);
h=get(a,'YLabel');
allHyl = [allHyl; h];
set(h,'Interpreter','latex');
set(h,'FontName',font);
set(h,'FontSize',FontSizeLabels);
h=get(a,'Title');
set(h,'Interpreter','latex');
set(h,'FontSize', FontSizeTitle);
% FontSizeTicks = 8;TODO
% h=get(ca,'ZLabel'); isfield
% set(h,'Interpreter','latex');
% set(h,'FontName','Times');
% set(a,'YLabel',10);
% set(a,'Title',FontSizeTitle);
% set(a,'Subtitle',20);
% h=get(ca,'xlabel');
end
% title("fontname","times")
% title( get(ca,'Title').String, 'interpreter','latex')
set(ca.Title,'Interpreter','latex');
% set(gca.Title,'xFontSize',20);
% set(gca,'FontSize',20);
end
%
% set(get(ca,'Xlabel'), ...
% 'FontUnits','points',...
% 'FontWeight','normal',...
% 'FontSize',FontSizeLabels,...
% 'Interpreter',valInterpreter,...
% 'FontName',font);
% set(get(ca,'Ylabel'),...
% 'FontUnits','points',...
% 'FontWeight','normal',...
% 'FontSize',FontSizeLabels,...
% 'Interpreter',valInterpreter,...
% 'FontName',font);
% set(get(ca,'Title'),...
% 'FontUnits','points',...
% 'FontWeight','normal',...
% 'FontSize',FontSizeTitle,...
% 'Interpreter',valInterpreter,...
% 'FontName',font);
% set(get(ca,'Legend'),...
% 'FontUnits','points',...
% 'FontSize',FontSizeLegend,...
% 'Interpreter',valInterpreter,...
% 'Location','NorthEast',...
% 'FontName',font);
end
%
% childs = get( gcf, 'Children' );
% for(childAxInx = 1:length(childs) )
% ca = childs(childAxInx);
% type = get( ca, 'type' );
% if type ~= "axes"
% continue
% end
% xlim(ca, valueAxis)
% ylim(ca, valueAxis)
% % set(ca, "axes", valueAxis); % not work because field is readOnly
% end
if(~skipYlabelPos)
values = [];
for(i = 1:numel(allHyl))
values = [values; allHyl(i).Position(1)];
end
% hist(values)
m = min(values)
for(i = 1:numel(allHyl))
% allHyl(i).Position(1)
allHyl(i).Position(1) = m;
end
end
x0=1920; y0=-160;
width=1280; height=1024;
set(gcf,'position',[x0,y0,width,height])
end
end
%-----------
if (~ismember(argStylePiotr, p.UsingDefaults))
if (valStylePiotr)
defaultInterpreter = "latex";
if (~ismember(argInterpreter, p.UsingDefaults))
defaultInterpreter = valInterpreter;
end
childs = get( gcf, 'Children' );
for(childAxInx = 1:length(childs) ) % for old type plots
ca = childs(childAxInx);
FontSizeTitle = 12;
FontSizeLabels = 10;
FontSizeTicks = 8;
FontSizeLegend = 8;
sgTitleFontSize = 15;
font = valFont;
type = get( ca, 'type' );
if( 1 == strcmp( type, 'axes' ))
set(ca,'FontSize',11); % fig in fig case
set(ca,'Box','on');
h=get(ca,'xlabel');
h.String = literateLATEX(h.String); % make polish letters for latex
% set(h, 'FontSize', 11)
set(h,'Interpreter',defaultInterpreter);
h=get(ca,'xaxis');
h.TickLabelInterpreter = defaultInterpreter;
h=get(ca,'ylabel');
h.String = literateLATEX(h.String);
% set(h, 'FontSize', 11)
set(h,'Interpreter',defaultInterpreter);
h=get(ca,'yaxis');
h.TickLabelInterpreter = defaultInterpreter;
h=get(ca,'zlabel');
h.String = literateLATEX(h.String);
% set(h, 'FontSize', 11)
set(h,'Interpreter',defaultInterpreter);
h=get(ca,'zaxis');
h.TickLabelInterpreter = defaultInterpreter;
h=get(ca,'title');
h.String = literateLATEX(h.String);
set(h,'Interpreter',defaultInterpreter);
h=get(ca,'subtitle');
h.String = literateLATEX(h.String);
set(h,'Interpreter',defaultInterpreter);
continue
end
if( 1 == strcmp( type, 'subplottext' ))
h = ca;
h.String = literateLATEX(h.String);
set(h,'Interpreter',defaultInterpreter);
continue
end
% set(ca,...
% 'FontName',font,...
% 'FontUnits','points',...
% 'FontWeight','normal',...
% 'FontSize',FontSizeTicks);
% type = get( ca, 'type' );
% set(findobj(gcf,'type','axes'),'FontName','Calibri','FontSize',11, ...
% 'FontWeight','Bold', 'LineWidth', 1,'layer','top');grid on
if( 1 == strcmp( type, 'legend' ))
h = ca;
h.String = literateLATEX(h.String);
set(h,'Interpreter',defaultInterpreter);
continue;
end
if( 1 == strcmp( type, 'tiledlayout' ))
gcaP = gca().Parent;
ch = gcaP.Children;
set(ca.Title,...
'FontName',font,...
'FontWeight','normal',...
'FontSize',sgTitleFontSize);
% nums = tilenum(flipud(gca))
for( i = 1:numel(ch))
a = ch(i);
atype = get( a, 'type' );
if( 1 == strcmp( atype, 'legend' ))
h = a;
h.String = literateLATEX(h.String);
set(h,'Interpreter',defaultInterpreter);
set(h,'FontName',font);
set(h,'FontSize',FontSizeLegend);
continue
end
% set(a,'FontSize', FontSizeLabels);
h=get(a,'XLabel');
h.String = literateLATEX(h.String);
set(h,'Interpreter',defaultInterpreter);
set(h,'FontName',font);
set(h,'FontSize',FontSizeLabels);
h=get(a,'YLabel');
h.String = literateLATEX(h.String);
set(h,'Interpreter',defaultInterpreter);
set(h,'FontName',font);
set(h,'FontSize',FontSizeLabels);
h=get(a,'Title');
h.String = literateLATEX(h.String);
set(h,'Interpreter',defaultInterpreter);
% set(h,'FontName',font);
set(h,'FontSize', FontSizeTitle);
% FontSizeTicks = 8;TODO
% h=get(ca,'ZLabel'); isfield
% set(h,'Interpreter','latex');
% set(h,'FontName','Times');
% set(a,'YLabel',10);
% set(a,'Title',FontSizeTitle);
% set(a,'Subtitle',20);
% h=get(ca,'xlabel');
end
% title("fontname","times")
% title( get(ca,'Title').String, 'interpreter','latex')
set(ca.Title,'Interpreter',defaultInterpreter); %??
% set(gca.Title,'xFontSize',20);
% set(gca,'FontSize',20);
end
%
% set(get(ca,'Xlabel'), ...
% 'FontUnits','points',...
% 'FontWeight','normal',...
% 'FontSize',FontSizeLabels,...
% 'Interpreter',valInterpreter,...
% 'FontName',font);
% set(get(ca,'Ylabel'),...
% 'FontUnits','points',...
% 'FontWeight','normal',...
% 'FontSize',FontSizeLabels,...
% 'Interpreter',valInterpreter,...
% 'FontName',font);
% set(get(ca,'Title'),...
% 'FontUnits','points',...
% 'FontWeight','normal',...
% 'FontSize',FontSizeTitle,...
% 'Interpreter',valInterpreter,...
% 'FontName',font);
% set(get(ca,'Legend'),...
% 'FontUnits','points',...
% 'FontSize',FontSizeLegend,...
% 'Interpreter',valInterpreter,...
% 'Location','NorthEast',...
% 'FontName',font);
end
%
% childs = get( gcf, 'Children' );
% for(childAxInx = 1:length(childs) )
% ca = childs(childAxInx);
% type = get( ca, 'type' );
% if type ~= "axes"
% continue
% end
% xlim(ca, valueAxis)
% ylim(ca, valueAxis)
% % set(ca, "axes", valueAxis); % not work because field is readOnly
% end
end
end
if (~ismember(argStyleGrid, p.UsingDefaults))
if (valStyleGrid)
arrayfun(@(x) grid(x,'on'), findobj(gcf,'Type','axes'))
arrayfun(@(x) grid(x,'minor'), findobj(gcf,'Type','axes'))
end
end
%----------- TiledLayout (spacing, padding)
if (~ismember(argTilePadding, p.UsingDefaults))
childs = get( gcf, 'Children' ); % old type, simple styled figure
for(childAxInx = 1:length(childs) )
ca = childs(childAxInx);
type = get( ca, 'type' );
if( 1 == strcmpi( type, 'tiledlayout' ))
gcaP = gca().Parent;
gcaP.Padding = valTilePadding;
end
end
end
% ---
if (~ismember(argTileSpacing, p.UsingDefaults))
childs = get( gcf, 'Children' );
for(childAxInx = 1:length(childs) )
ca = childs(childAxInx);
type = get( ca, 'type' );
if( 1 == strcmpi( type, 'tiledlayout' ))
gcaP = gca().Parent;
gcaP.TileSpacing = valTileSpacing;
end
end
end
%%%%%%% Size %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% valFigUnits pixels, points, cale
% TODO
% if(valDimX ~= 1)
% PosFig = get(gcf,'Position');
% PosFig(3) = PosFig(3)*valScaleX;
% set(gcf, 'Position', PosFig);
% end
%
% if(valDimY ~= 1)
% PosFig = get(gcf,'Position');
% PosFig(4) = PosFig(4)*valScaleY;
% set(gcf, 'Position', PosFig);
% end
%%%%%%% Scaling figure - position %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if(valScale ~= 1)
PosFig = get(gcf,'Position');
PosFig(3:4) = PosFig(3:4)*valScale;
set(gcf, 'Position',PosFig);
end
if(valScaleX ~= 1)
PosFig = get(gcf,'Position');
PosFig(3) = PosFig(3)*valScaleX;
set(gcf, 'Position', PosFig);
end
if(valScaleY ~= 1)
PosFig = get(gcf,'Position');
PosFig(4) = PosFig(4)*valScaleY;
set(gcf, 'Position', PosFig);
end
if (~ismember(argMaxF, p.UsingDefaults))
% if(valMaxF)
% a = get(gcf,'Position');
% gcf.WindowState = 'maximized';
set(gcf, 'Position', get(0, 'Screensize'));
% jFrame = get(handle(gcf),'JavaFrame');
% jFrame.setMaximized(true);
% end
end
if (~ismember(argGoldenRatio, p.UsingDefaults))
if(valGoldenRatio)
defaultSize = 1000*valGoldenRatio; %px absolut scaling standard
if(valGoldenRatio==1) defaultSize = gcf().Position(3); end
set(gcf, 'Units', 'pixels');
if(valGoldenRatio < 0)
% or if in browser?
defaultSize = 3.25*abs(valGoldenRatio); %inches [colummn size in trnse]
set(gcf, 'Units', 'inches');
end
GOLDEN_RATIO = 1.618033988749894848204586834365638;
set(gcf, 'Position', [1 1 defaultSize*GOLDEN_RATIO defaultSize]);
end
end
%%%%%%% ylabel rePositon %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if (~ismember(argRePositonYlabel, p.UsingDefaults))
if(valRePositonYlabel)
% for gcf, all axis get ylabel pos, get max and set to all ax
end
end