How to compare multiple patch objects (mesh) on same colorbar scale?

2 vues (au cours des 30 derniers jours)
Jonathan Gustafson
Jonathan Gustafson le 21 Juin 2016
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.

Réponses (1)

Muhammad Usman Saleem
Muhammad Usman Saleem le 21 Juin 2016
Use freeze or unfreeze demo.You may get the function from the link: http://in.mathworks.com/matlabcentral/fileexchange/7943-freezecolors---unfreezecolors
  1 commentaire
Jonathan Gustafson
Jonathan Gustafson le 21 Juin 2016
I am not sure if I made it clear as to what I am trying to do...As an example, let's say I have 3 patch objects, same size. I am trying to display the selected faces for each patch object based on the value of vin (stress in my case) from the function in the main post, as opposed to simply "freezing" the color image of each patch object. So for patch object 1, vin is double size of 3102 x 1; patch object 2, vin is double size of 2728 x 1; patch object 3, vin is double size of 2129 x 1, where each row is a value of stress associated with a particular face in the entire patch object (size of 17483 x 3). I am trying to generate a contour plot using these 3 different vin values, but so that the colormap/colorbar for all 3 are on the same scale, thus allowing me to visualize the difference between the 3. So using a typical "jet" color scheme, higher values will be red while low values will be blue. Is this more clear? From what I read about the freeze and unfreeze demo, all it will do is scale the colormap based on each individual min/max vin (stress) value and then lock that color scheme, which does not help me in visualizing all 3 on the same colormap to see differences. Thank you for your help!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Colormaps dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by