Is it possible to use a section of a colormap?

43 visualizzazioni (ultimi 30 giorni)
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 Commenti
Sean de Wolski
Sean de Wolski il 22 Ott 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.
Matthew
Matthew il 22 Ott 2013
The redrawsmithchart function mentioned uses my plot_colorfade(x,y) function in code I have omitted. When it is called x = real gamma values and y = imaginary gamma values. These values are individual coordinates which the jet colormap is used to plot within the plot_colorfade function.

Accedi per commentare.

Risposta accettata

Jeremy
Jeremy il 21 Ott 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
  1 Commento
Matthew
Matthew il 22 Ott 2013
Thank you for the answer! I was able to get my code to work by modifying my plot_colorfade function and adding the lines:
CMAP_LENGTH = 256;
colormin = round((newLim(1)/initial_endtime)*256);
colormax = round((newLim(2)/initial_endtime)*256);
d = jet(CMAP_LENGTH);
cmap = colormap(d(colormin:colormax,:));
where newLim is a global variable for the x limits that is set during a zoom actionpostcallback and initial_endtime is the x max before the zoom actionpostcallback.

Accedi per commentare.

Più risposte (1)

John Barber
John Barber il 22 Ott 2013
Modificato: John Barber il 22 Ott 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.

Categorie

Scopri di più su Colormaps in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by