Is it possible to use a section of a colormap?
45 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am using a Matlab gui the has multiple graphs. One of these graphs is a smith chart, which plots coordinates in the complex plane. Each graph is plotted using a custom plot_colorfade(x,y,varargin) function. This function uses the default colormap "jet" and plots the collection of coordinates that are gathered from an external file as a color fade. Right now I have implemented a zoom function that when used on a first graph (tag: handles.del_pwr) it takes the new x (time) limits in a ActionPostCallback and redraws the smith chart with these new time limits.
Whenever I use the zoom feature I can focus on a section of the colorfade. However, when the smith chart is redrawn with the new x limits the colorfades between the two graphs do not match. For example, I can focus on the green-yellow section of the standard blue to red 'jet' colormap. When this happens, the limits of the smith chart are drawn to the new x limits of the handles.del_pwr graph but the color fade remains as the standard "jet" color fade (blue to red) regardless of the starting/ending point.
What I am wondering is if it is possible to use only a section of the "jet" colormap? (From my example above, I would want the green-yellow section for the smith chart starting at the same x coordinates as the handles.del_pwr graph colorfade). If hiding points of a graph without disturbing the colormap is possible that could potentially be a solution too.
Note: Using something such as linkaxes when zooming is not possible in this case because the smith chart and handles.del_pwr graphs don't use the same coordinate systems.
I can post the code for my plot_colorfade function and elaborate more if it is needed.
2 commentaires
Sean de Wolski
le 22 Oct 2013
It's certainly possible. If you could provide a simple minimal working example, it would help us a lot.
It sounds to me like you'll need to set a few properties of the various lines, and perhaps change the CDataMapping property in order to force the limits. However, and example would clarify this.
Réponse acceptée
Jeremy
le 21 Oct 2013
you can define a colormap using the jet(n) function where n is the number of steps. Based on the min/max of the current window you could limit the portion of the colormap to use. With a large n, it should work pretty well. You have to figure out exactly how to integrate.
example:
d=rand(100)*100;
image(d);
c=jet(100);
colormap(c(1:50,:)); %only uses the cold portion of the color map
%colormap(c(50:100,:)); %only uses the warmportion of the color map
Plus de réponses (1)
John Barber
le 22 Oct 2013
Modifié(e) : John Barber
le 22 Oct 2013
The caxis function lets you adjust the axes' color limits ( CLim property), which determine the range of data values that are mapped to the colormap (for plots using 'scaled' CDataMapping, but not 'direct' ). See here for details: www.mathworks.com/help/matlab/ref/caxis.html.
0 commentaires
Voir également
Catégories
En savoir plus sur Colormaps dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!