Is it possible to use a section of a colormap?
46 次查看(过去 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!