How to compare multiple patch objects (mesh) on same colorbar scale?
4 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
Muhammad Usman Saleem
2016-6-21
Use freeze or unfreeze demo.You may get the function from the link: http://in.mathworks.com/matlabcentral/fileexchange/7943-freezecolors---unfreezecolors
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Colormaps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!