Prev: In an assignment A(I) = B, the number of elements in B and I must be the same.
Next: Implementing FIR filters with exponential roll off
From: nan on 21 Sep 2009 04:50 hello everyone, i try to plot a figure with a zoom out plot within the figure. the codes are show at the bellow, the problem is, the axes for the zoom out plot doesnt change as the limits given in the code. can anyone help me please! many thanks nan %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all close all cell_total_user=0:1680; collided=0:1680; x1=cell_total_user*1; x2=collided*1; p3=plot(cell_total_user,x1,collided,x2) hkids = get(gca,'child') set(hkids(1), 'marker', '*') set(hkids(2), 'marker', 'o') ax1 = gca; ax2 = axes('Position',get(ax1,'Position'),... 'XAxisLocation','top',... 'YAxisLocation','right',... 'Color','none',... 'XColor','k','YColor','k'); set(ax2,'xlim',[200 300])% axes limit for zoom out, set(ax2, 'Units', 'normalized', 'Position', [0.25 0.65 0.25 0.25]) plot(cell_total_user,x1,collided,x2, 'marker','*') % plot in zoom axes
From: Sebastiaan on 21 Sep 2009 05:32 You have to plot the data first, then set the limits. Otherwise, the limits are adjusted to the new plot. Also, all your axes properties are ignored now (location, colour, etc.). You have to add the option NextPlot (same as the 'hold on' command). A more "robuust" piece of code is this, where you create your axes first, and then plot to that specific axes, in stead of relying on the current gca: clear all close all cell_total_user=0:1680; collided=0:1680; x1=cell_total_user*1; x2=collided*1; ax1 = axes; % create axes p3=plot(ax1, cell_total_user,x1,collided,x2) % plot to ax1 hkids = get(ax1, 'child') % get ax1 properties set(hkids(1), 'marker', '*') set(hkids(2), 'marker', 'o') ax2 = axes('Position',get(ax1,'Position'),... 'XAxisLocation','top',... 'YAxisLocation','right',... 'Color','none',... 'XColor','k','YColor','k', 'NextPlot', 'add'); % make ax2. Use nexplot to maintain your settings plot(ax2, cell_total_user,x1,collided,x2, 'marker','*') % plot in zoom axes set(ax2,'xlim',[200 300])% axes limit for zoom out, set(ax2, 'Units', 'normalized', 'Position', [0.25 0.65 0.25 0.25]) "nan " <njyan2005(a)yahoo.co.uk> wrote in message <h97eob$34j$1(a)fred.mathworks.com>... > hello everyone, > i try to plot a figure with a zoom out plot within the figure. the codes are show at the bellow, the problem is, the axes for the zoom out plot doesnt change as the limits given in the code. can anyone help me please! > > many thanks > nan > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% > clear all > close all > cell_total_user=0:1680; > collided=0:1680; > x1=cell_total_user*1; > x2=collided*1; > p3=plot(cell_total_user,x1,collided,x2) > hkids = get(gca,'child') > set(hkids(1), 'marker', '*') > set(hkids(2), 'marker', 'o') > ax1 = gca; > ax2 = axes('Position',get(ax1,'Position'),... > 'XAxisLocation','top',... > 'YAxisLocation','right',... > 'Color','none',... > 'XColor','k','YColor','k'); > set(ax2,'xlim',[200 300])% axes limit for zoom out, > set(ax2, 'Units', 'normalized', 'Position', [0.25 0.65 0.25 0.25]) > plot(cell_total_user,x1,collided,x2, 'marker','*') % plot in zoom axes
From: nan on 21 Sep 2009 06:00
Thank you very much, Sebastiaan! nan "Sebastiaan" <s.breedveld(a)erasmusmc.REMOVE.BOO.BOO.nl> wrote in message <h97h6j$33q$1(a)fred.mathworks.com>... > You have to plot the data first, then set the limits. Otherwise, the limits are adjusted to the new plot. Also, all your axes properties are ignored now (location, colour, etc.). You have to add the option NextPlot (same as the 'hold on' command). > > A more "robuust" piece of code is this, where you create your axes first, and then plot to that specific axes, in stead of relying on the current gca: > clear all > close all > cell_total_user=0:1680; > collided=0:1680; > x1=cell_total_user*1; > x2=collided*1; > > ax1 = axes; % create axes > p3=plot(ax1, cell_total_user,x1,collided,x2) % plot to ax1 > hkids = get(ax1, 'child') % get ax1 properties > set(hkids(1), 'marker', '*') > set(hkids(2), 'marker', 'o') > > ax2 = axes('Position',get(ax1,'Position'),... > 'XAxisLocation','top',... > 'YAxisLocation','right',... > 'Color','none',... > 'XColor','k','YColor','k', 'NextPlot', 'add'); % make ax2. Use nexplot to maintain your settings > plot(ax2, cell_total_user,x1,collided,x2, 'marker','*') % plot in zoom axes > set(ax2,'xlim',[200 300])% axes limit for zoom out, > set(ax2, 'Units', 'normalized', 'Position', [0.25 0.65 0.25 0.25]) > > > > > "nan " <njyan2005(a)yahoo.co.uk> wrote in message <h97eob$34j$1(a)fred.mathworks.com>... > > hello everyone, > > i try to plot a figure with a zoom out plot within the figure. the codes are show at the bellow, the problem is, the axes for the zoom out plot doesnt change as the limits given in the code. can anyone help me please! > > > > many thanks > > nan > > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% > > clear all > > close all > > cell_total_user=0:1680; > > collided=0:1680; > > x1=cell_total_user*1; > > x2=collided*1; > > p3=plot(cell_total_user,x1,collided,x2) > > hkids = get(gca,'child') > > set(hkids(1), 'marker', '*') > > set(hkids(2), 'marker', 'o') > > ax1 = gca; > > ax2 = axes('Position',get(ax1,'Position'),... > > 'XAxisLocation','top',... > > 'YAxisLocation','right',... > > 'Color','none',... > > 'XColor','k','YColor','k'); > > set(ax2,'xlim',[200 300])% axes limit for zoom out, > > set(ax2, 'Units', 'normalized', 'Position', [0.25 0.65 0.25 0.25]) > > plot(cell_total_user,x1,collided,x2, 'marker','*') % plot in zoom axes |