limit the axes for plotting in Matlab [duplicate]

懵懂的女人 提交于 2019-11-30 06:09:44

问题


Possible Duplicate:
is it possible to select a particular region in a scatterplot

is it possible to reduce the datapoints from the input text file, so that those dont come in my calculation. I am using following to read the data

fid = fopen('cr.txt');
A =  textscan(fid, '%f %f %f %f %f %*f %*f %*f %*f %*f %*s %*s %*s') ;
%read the file
a = A{1};
e = A{2};
c = A{3};
x = A{4};
y = A{5};

here x,y are the distances and if I apply xlim and ylim, I want to limit the corresponding a,e,c from the file also. the file has around million data points.

And I will be further plotting the x,y and z(which is calculated from a,e,c) as a scatter and colorbar the plotting code I am using for the entire data points is

lg=log10(g2);
scatter(x(1:end-1), y(1:end-1),5, lg);
colorbar('eastoutside');
caxis([14 max(lg)]);
xlabel(' X-axis (microns)');
ylabel('Y-axis (microns)');

the lg is determined from the a,e,c shown earlier. so all I want to do is do a plot between a selected portion of x,y and the corresponding lg.

please help!!


回答1:


Yes you can specify the limits directly on the axes using set or by calling the xlim, ylim, and zlim functions

plot(rand(1,100));
set(gca,'XLim', [10 20] ); % set the xlims to 10,20

or

plot(rand(1,100));
xlim([10 20]); % set the xlims to 10,20



回答2:


Well, this is probably too obvious to be the solution to your problem, but in this line:

scatter(x(1:end-1), y(1:end-1),5, lg);

If lg is the same size as x and y, then clearly this is wrong and you need to do:

scatter(x(1:end-1), y(1:end-1),5, lg(1:end-1));

If this does not solve your problem, then as I stated in my comment you must provide complete code that we can run to reproduce the problem, including sample data for the x, y, and lg vectors.



来源:https://stackoverflow.com/questions/13494693/limit-the-axes-for-plotting-in-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!