how to zoom in on specific overlapped data points and keepin the others ones inside the grid range

Hello, I have a set of data I am analyzing and I would like some help if you can. My data consist of two columns but my X column is only one point and my Y colunm is about 50 points. So when I plot it of course it's just just diff points along the Y axis versus one single point on the x axis.
Now those points are really closed to each other and what I would like to do is to label each point to their actual Channel name. But so far I tried to use the text() function an it gives me an error saying that my x and y value should be the same. I'm not sure which way to do this anymore. Keep in mind that I have the names of each data points in a file also. Can you help? Keep in mind using one x value and 50 Y values. Lets say I fix it and now the names are on top of each other. Is there a way I am space them out without affecting the location of the points.
Thanks for your help in advance!

2 Comments

@ jonathan, the error messgae I get is X,Y should be the same length.
and it is because my Y has 50 data points and my X has only one.

Sign in to comment.

Answers (1)

Okay, either you're not explaining well, or the solution is very simple: If the data doesn't have the same dimension, then make it.
Either, you make an array with all the channel names, then use text once:
M = [repmat('Channel ',50,1) num2str((1:50)', '%2d')];
plot(1,1:50,'s');
text(ones(50,1)+.1,1:50,M);
or you use a for-loop:
plot(1,Y,'s');
for ii=1:50
text(1+.1, Y(ii), num2str(ii,'Channel %d'));
end
Does that help?

10 Comments

Not quite. Because my data are from a file and the channel names are different. As for dimension, y has 50 values. But c can only have one. But I can Add dummy values to x to make it the same length as y But these values has to be the same.
I'm using 4 different files. I had 4 plots in one figure. So I open them using
fid=dlmread('filename')
fid1=dlmread('filename')
fid2=dlmread('filename')
fid3=dlmread('filename')
Then I read through them to get the specific data that I want
L1= fid([1:49],1)
L2= fid1([1:49],1)
L3=fid2([1:49],1)
L4= fid3([1:49],1)
Then I get the x axis which is one line
T1= fid (60,1)
And plot
hold on
Plot(T1,L1)
And plot the rest the same way
But I want to label each of these data points with names. Such as channel 1 , channel 2, channel 3 and so on on the graph ad if possible space them out so the name don't pile up on each other
I fixed the labeling problem but now My data points are too closed to each other that The labels are all on top of each other... But they follow the same display pattern as the data points.... the ones that are on top of each other are because the points are on top of each other...what can I do to fix that.
You could try and alternate the alignment of the labels, i.e. have the lowest label on the right, the next on the left, the next one on the right again and so on. Example:
Y = randi(300,[50 1]);
[Ys, i0] = sort(Y);
plot(1,Y,'s');
for ii=1:50
if mod(ii,2)
text(1+.1, Y(i0(ii)), num2str(ii,'Channel %d'));
else
text(1-.1, Y(i0(ii)), ...
num2str(ii,'Channel %d'),'HorizontalAlignment','Right');
end
end
Depending on whether your data is already sorted, you might be able to skip the sorting step.
That will help you, if the points aren't in clusters of 3 or more, but in that case I really don't know what a solution could look like. Lines connecting the text labels to the corresponding dots?
Thanks Jonathan, but apparently the main problem is to zoom in on few specific points that are overlapped and to make sure that they all fit inside the grid. But every time i try to play with the Yaxis( using Ytick, and axis([xmin xmax ymin ymax]) and zoom(), i can see the ones that are overlapped all spaced out but the other ones end up outside the grid. I used Ytick and Xtick with set(gca, 'Ytick', ' ') but that stopped the text function from working and disabled the labels. Any ideas?
Let's just say you have as straight line that constitutes of points. and there are 50 points on that line but some of them are so closed to each other that they look like they overlap. YOu and all of them to clearly appear on the line. when you zoom in on the overlapped ones the other points get out of the axis range. but what you really want is to be able to zooom in on the overlapped ones and make them appear clearly and not affect the visibility of the other ones. That way a good copy of the figure can be taken.
Can you upload some images, plots, screenshots, or anything to illustrate what you're talking about? Like to http://snag.gy
I think I'm not sure anymore, what it really is you want. Maybe you do what Image Analyst suggested, and maybe you outline, what it is exactly that you want to visualize: Is it just value vs a channel name? Then what's wrong with a simple table? Or maybe a bar chart, where you have a bar for every channel? Why does it have to be boxes on a single line?
here's the link: http://snag.gy/gZksi.jpg
you ll see the area i'm trying to zoom in on without affecting the others
So you'd like some kind of magnifying glass? Maybe an inset axis might be what your are looking for: http://www.mathworks.com/matlabcentral/fileexchange/33159-inset2dabsolute
Or you could distort the y-axis, so that the scale in the center is smaller than on the edges.
I have no idea how else you would zoom in without losing the other data points.
@ john,didnt quite do the job..but thanks for all your input. It was well appreciated.

Sign in to comment.

Products

Asked:

on 18 Apr 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!