Is it possible to use a section of a colormap?
조회 수: 22 (최근 30일)
이전 댓글 표시
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
Sean de Wolski
2013년 10월 22일
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.
채택된 답변
Jeremy
2013년 10월 21일
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개)
John Barber
2013년 10월 22일
편집: John Barber
2013년 10월 22일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Colormaps에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!