assign differernt marker and put an offset in x-axis in subplot()
Mostrar comentarios más antiguos
I have an array y(15 rows, 80 columns) and x(1,80) and want to plot each row of y against x.
I wonder how I can assign differernt marker to each plot. there are 15 rows in array y so I need 15 different markers.
I also wonder how I can put an offset in x-axis since the markers for the first x and y falls on y axis.
I would be grateful for your help.
x=1:80;
y=rand(15,80);
j=1;
for i=1:16
subplot(6,3,i),plot(x(j:j+4),y(:,j:j+4),'LineStyle','none','Marker'
,'+')
j=j+5;
end
Respuesta aceptada
Más respuestas (1)
Jarrod Rivituso
el 5 de Mayo de 2011
Two comments
- You can easily plot a group of lines using a single call to the plot function if you arrange each column of the y matrix to be a separate line plot's data (so, make it 80-by-15 instead of 15-by-80)
- You can get a list of all available markers (there are 13 of them) from the set function
Here's an example
x = (1:80)';
y = rand(80,15);
plotHandles = plot(x,y,'Linestyle','none');
markerNames = set(plotHandles(1),'Marker');
for i = 1:length(plotHandles)
markerIndex = mod(i,13)+1
set(plotHandles(i),'Marker',markerNames{markerIndex});
end
4 comentarios
Teja Muppirala
el 5 de Mayo de 2011
Jarrod, in this case he's doing 5 points at a time, on 16 different subplots, so I don't think he can just plot it all at once.
Teja Muppirala
el 5 de Mayo de 2011
But this was very clever:
markerNames = set(plotHandles(1),'Marker');
It had never occurred to me that you could do that.
Jarrod Rivituso
el 5 de Mayo de 2011
oops, i read it quickly. good point Teja :)
Hassan
el 5 de Mayo de 2011
Categorías
Más información sobre Subplots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!