From: SS C on
I have two vectors a and b and I want to plot(a,b). However, the vector a has irregularly spaced values such as a = [5000,1, 30,2000]. I want to see plot([1:length(b)],b) but overlaid with the values in vector a for the labeling of the x axis. How can I do so? (i.e. I want to ignore the values of a, but I want to see in them in the labels, something like a categorical plot). Thanks!
From: Wayne King on
"SS C" <sschiang8(a)gmail.com> wrote in message <i3sef0$m49$1(a)fred.mathworks.com>...
> I have two vectors a and b and I want to plot(a,b). However, the vector a has irregularly spaced values such as a = [5000,1, 30,2000]. I want to see plot([1:length(b)],b) but overlaid with the values in vector a for the labeling of the x axis. How can I do so? (i.e. I want to ignore the values of a, but I want to see in them in the labels, something like a categorical plot). Thanks!

Hi,

b = randn(4,1);
plot(b)
set(gca,'xtick',1:length(b))
set(gca,'xticklabel',{'5000','1', '30','2000'})

Hope that helps,
Wayne
From: Ross W on
"SS C" <sschiang8(a)gmail.com> wrote in message <i3sef0$m49$1(a)fred.mathworks.com>...
> I have two vectors a and b and I want to plot(a,b). However, the vector a has irregularly spaced values such as a = [5000,1, 30,2000]. I want to see plot([1:length(b)],b) but overlaid with the values in vector a for the labeling of the x axis. How can I do so? (i.e. I want to ignore the values of a, but I want to see in them in the labels, something like a categorical plot). Thanks!

Hi

you can do this:
plot(b)
set(gca,'XTick',1:length(b))
set(gca,'XTickLabel',num2str(a(:)))

If you want the 'a' label next to the data point instead, use the text function

Ross
From: SS C on
Thanks! it works well =)

"Wayne King" <wmkingty(a)gmail.com> wrote in message <i3sfb6$i02$1(a)fred.mathworks.com>...
> "SS C" <sschiang8(a)gmail.com> wrote in message <i3sef0$m49$1(a)fred.mathworks.com>...
> > I have two vectors a and b and I want to plot(a,b). However, the vector a has irregularly spaced values such as a = [5000,1, 30,2000]. I want to see plot([1:length(b)],b) but overlaid with the values in vector a for the labeling of the x axis. How can I do so? (i.e. I want to ignore the values of a, but I want to see in them in the labels, something like a categorical plot). Thanks!
>
> Hi,
>
> b = randn(4,1);
> plot(b)
> set(gca,'xtick',1:length(b))
> set(gca,'xticklabel',{'5000','1', '30','2000'})
>
> Hope that helps,
> Wayne