-1

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!!

Community
  • 1
  • 1
  • If I understand correctly, `xlim` and `ylim` will do exactly what you want. So I must not understand the question! Have you tried using `xlim` and `ylim` and they failed? Note that you don't have to work with the entire million-point data set, just create a smaller data set for testing your plotting code. – Dan Becker Nov 21 '12 at 14:26
  • @DanBecker Yup xlim and ylim can limit them, but what about the corresponding z? how can I limit the z to the selected x and y points. – Rohan Chakrabarty Nov 21 '12 at 14:29
  • Can you post your plotting code, and explain the exact problem you are having with it? Include a (very small) set of data so that we can all reproduce the problem. – Dan Becker Nov 21 '12 at 14:35
  • @DanBecker can u please guide me with this – Rohan Chakrabarty Nov 21 '12 at 14:45
  • Can you please also include example values for the vectors `x`, `y` and `lg` so that we can reproduce the error? – Dan Becker Nov 21 '12 at 16:29

2 Answers2

0

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
slayton
  • 20,123
  • 10
  • 60
  • 89
  • I had tried using it but I am getting the following error ??? Error using ==> scatter at 79 C must be a single color, a vector the same length as X, or an M-by-3 matrix. probably because z which is derived from a,e,c cannot be limited as x and y can – Rohan Chakrabarty Nov 21 '12 at 15:55
  • @RohanChakrabarty, I'm not sure that error has anything to do with setting limits. Post a new question and I'll help you with it. – slayton Nov 21 '12 at 18:33
0

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.

Dan Becker
  • 1,196
  • 10
  • 18