How to compare multiple patch objects (mesh) on same colorbar scale?
조회 수: 2 (최근 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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/154299/image.jpeg)
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!