|
| 1 | +function PlotFR(mesh, odf, varargin) |
| 2 | + |
| 3 | +CheckMesh(mesh, odf) % check sizes |
| 4 | +% |
| 5 | +crd = mesh.crd; % Unpack input structures. |
| 6 | +con = mesh.con; |
| 7 | +eqv = mesh.eqv; |
| 8 | +% |
| 9 | +%odf = ToAllNodes(odf, eqv); |
| 10 | +% |
| 11 | +%--------------------Defaults and Options------------------------------- |
| 12 | +% |
| 13 | +optcell = {... |
| 14 | + 'Symmetries', 'cubic', ... |
| 15 | + 'ShowMesh', 'off', ... |
| 16 | + 'Colormap', [], ... |
| 17 | + 'BrightenColormap', 0, ... |
| 18 | + 'NumberOfColors', 64 ... |
| 19 | + }; |
| 20 | +% |
| 21 | +opts = OptArgs(optcell, varargin); |
| 22 | +% |
| 23 | +symtype = opts.Symmetries; |
| 24 | +% |
| 25 | +% Colormap. |
| 26 | +% |
| 27 | +cmap = opts.Colormap; |
| 28 | +if (isempty(cmap)) % default colormap |
| 29 | + cmap = jet(opts.NumberOfColors); |
| 30 | +end |
| 31 | +bright = opts.BrightenColormap; |
| 32 | +cmap = bright + (1 - bright)*cmap; |
| 33 | +% |
| 34 | +% Surface options. |
| 35 | +% |
| 36 | +plotsurfopts = {'ShowMesh', opts.ShowMesh}; |
| 37 | +% |
| 38 | +%-------------------- Build figure. |
| 39 | +% |
| 40 | +f = figure; |
| 41 | +% |
| 42 | +colormap(cmap); |
| 43 | +% |
| 44 | +figscale = 1.0; % figure scale |
| 45 | +% |
| 46 | +% Reshape figure to reflect the 1x2 array of subplots. |
| 47 | +% |
| 48 | +vertscale = 0.6; |
| 49 | +% |
| 50 | +pos = get(f, 'Position'); |
| 51 | +pos(4) = pos(4)*vertscale; |
| 52 | +% |
| 53 | +set(f, 'Position', pos); |
| 54 | +%-------------------- *** Subplot 1 (surface) |
| 55 | +% |
| 56 | +subplot(1, 2, 1) |
| 57 | +% |
| 58 | +% The first plot shows the surface, and the range of data |
| 59 | +% is complete since the surface plot uses the same nodal point |
| 60 | +% array, but only the surface elements. |
| 61 | +% |
| 62 | +[faces, multiplicity] = MeshFaces(con); |
| 63 | +scon = faces(:, (multiplicity == 1)); |
| 64 | +surfmesh = MeshStructure(crd, scon, eqv); |
| 65 | +% |
| 66 | +PlotSurface(surfmesh, odf, plotsurfopts{:}); |
| 67 | +% |
| 68 | +% Axes. |
| 69 | +% |
| 70 | +axis off |
| 71 | +% |
| 72 | +a11 = gca; |
| 73 | +clim = get(a11, 'CLIM'); % save color range for next plot |
| 74 | +% |
| 75 | +% Colorbar. |
| 76 | +% |
| 77 | +% This positions the colorbar in the middle of the figure. |
| 78 | +% The vertical size is 90% that of the axes, while the default |
| 79 | +% width remains the same. |
| 80 | +% |
| 81 | +% Position = [left bottom width height] |
| 82 | +% |
| 83 | +cb = colorbar; |
| 84 | +pos_a11 = get(a11, 'Position'); % save position after creation of colorbar |
| 85 | +poscb = get(cb, 'Position'); |
| 86 | +% |
| 87 | +poscb(4) = 0.9*pos_a11(4); |
| 88 | +poscb(1) = 0.5 - 0.5*poscb(3); |
| 89 | +poscb(2) = 0.5 - 0.5*poscb(4); |
| 90 | +% |
| 91 | +set(cb, 'Position', poscb); |
| 92 | +% |
| 93 | +PlotFRPerimeter(symtype); |
| 94 | +% |
| 95 | +%-------------------- *** Subplot 2 (slices) |
| 96 | +% |
| 97 | +subplot(1, 2, 2) |
| 98 | +% |
| 99 | +% The second plot shows the slices and uses the same data |
| 100 | +% as the first plot, so that the colorbar is identical. |
| 101 | +% |
| 102 | +PlotFRSlices(mesh, ToAllNodes(odf, eqv), symtype) |
| 103 | +% |
| 104 | +% Adjust axes. |
| 105 | +% |
| 106 | +a12 = gca; |
| 107 | +% |
| 108 | +% Make same size as other axes. |
| 109 | +% |
| 110 | +pos_a12 = pos_a11; |
| 111 | +pos_a12(1) = 1 - pos_a12(1) - pos_a12(3); |
| 112 | +set(a12, 'CLIM', clim, 'Position', pos_a12); |
0 commit comments