Hello, I am using MATLAB R2015b and am having difficulty generating contour plots to compare multiple patch objects to see differences between the objects. In short, I have been using the cmap, patch and colorbar features to generate contour plots for individual patch objects based on calculations I am making (stress levels of subject-specific knee joint models). What I would like to do is be able to bring in the results from multiple patch objects (i.e. different stress levels) and plot them all with the same colormap contour so that I can visualize the differences in the "stress values". Here is some code I have written to visualize each individual patch object:
function [vin_sort,elem_sort,cmap_scaled] = cmap_plot(mesh_tri,vin,vin_whole,label)
%cmap_plot takes the input of mesh_tri, vin, vin_whole, and label to %generate contour plots of certain variables across a patch object.
%mesh_tri = triangulated data with mesh_tri.ConnectivityList and %mesh_tri.Points
%vin = variable of interest to generate a contour plot for specific faces %in mesh_tri; vin_whole is variable of interest with values across the %entire patch object
%label = printed label for the colorbar
[vin_sort,vin_index] = sort(vin_whole,'ascend'); [c_index] = find(vin_sort>0,1); elem_sort = mesh_tri.ConnectivityList(vin_index,:); cmap = colormap('jet'); cmap_scaled = zeros(length(elem_sort),3); cmap_scaled(1:c_index-1,:) = repmat(cmap(1,:),c_index - 1,1); cmap_scaled(c_index:end,:) = interp1(linspace(0,1,length(cmap(1:50,:))),cmap(1:50,:),linspace(0,1,length(vin))); patch('Faces',elem_sort,'Vertices',mesh_tri.Points,'FaceVertexCData',cmap_scaled,'FaceColor','flat'); axis equal;hold on;%patch('Faces',pbone_loaded.ConnectivityList,'Vertices',pbone_loaded.Points,'FaceColor','magenta'); h = colorbar;h.Limits = [min(vin) max(vin)]; caxis([min(vin) max(vin)]);xlabel(h,label); set(h,'fontsize',18); end
When I run this, I get a nice contour plot across my single patch object:
I have multiple additional patch objects with varying "stress level" (vin for the function) and wanted to be able to generate one cmap color scale that will allow me to visualize the differences between the different patch objects. Any help or guidance would be greatly appreciated.