Plot axis limits

3 visualizaciones (últimos 30 días)
Steve D
Steve D el 10 de Nov. de 2011
I am wasting my life trying to get the axes to go from a to b (ONLY!).
For example, the data file goes from 290 to 420 (variable) in steps of .02. I plot all rows and one column. There are 6500 rows. But Matlab insists on making the axes go from 0 to 7000 leaving whitespace at the end. If I add a line command within the x axis range, sometimes it creates two lines instead of one. Why is plotting so flakey?

Respuestas (2)

Honglei Chen
Honglei Chen el 10 de Nov. de 2011
You can give following command a try
axis tight
If you want more control, you can use axis command to control the limits
doc axis
HTH
  1 comentario
Steve D
Steve D el 10 de Nov. de 2011
Doesn't work, tried it.

Iniciar sesión para comentar.


Jonathan
Jonathan el 10 de Nov. de 2011
You can set the axis limits using ylim([290 420]) or xlim([290 420]).
  3 comentarios
Jonathan
Jonathan el 10 de Nov. de 2011
Please post your original code.
Steve D
Steve D el 11 de Nov. de 2011
Here is a sample section:
% Read Parmeters:
fid = fopen(temp, 'r'); % fn = function parameter
frewind(fid);
for i=1:5 trash=fgetl(fid); end; % skip 1st 5 lines
params = cell2mat( textscan(fid, '%f',19) ); % read line 6
stimre = params(5); % grab the re stim start time parameter
stimredur = params(6); % and the duration
strest = num2str(params(5)); % convert to strings for labeling plots
stimcx = params(12); % grab the cx stim start time parameter
stimcxdur = params(13); % and the duration
stcxst = num2str(params(12)); % convert to strings for labeling plots
cxno = fscanf(fid, '%d',1); % read number of each cell to plot for each pop
cxnost = num2str(cxno); % and convert to a string for plot labels
inno = fscanf(fid, '%d',1);
innost = num2str(inno);
tcno = fscanf(fid, '%d',1);
tcnost = num2str(tcno);
reno = fscanf(fid, '%d',1);
renost = num2str(reno);
startplot1 = fscanf(fid, '%d',1); % read start and end time for each plot
endplot1 = fscanf(fid, '%d',1);
endplot1 = endplot1; % decrement to ensure plots do not have white space
st1 = num2str(startplot1); % convert to string for plot labels
et1 = num2str(endplot1);
startplot2 = fscanf(fid, '%d',1);
endplot2 = fscanf(fid, '%d',1);
endplot2 = endplot2;
st2 = num2str(startplot2);
et2 = num2str(endplot2);
startplot3 = fscanf(fid, '%d',1);
endplot3 = fscanf(fid, '%d',1);
endplot3 = endplot3;
st3 = num2str(startplot3);
et3 = num2str(endplot3);
startplot4 = fscanf(fid, '%d',1);
endplot4 = fscanf(fid, '%d\n',1);
endplot4 = endplot4;
st4 = num2str(startplot4);
et4 = num2str(endplot4);
msb = 5; % millisenconds per bin
mst = num2str(msb); % string version for bin plot labels
.
.
.
.
.
.
.
if endplot4 > 0
figure(9);
hold on;
set(gcf,'Name', paramline);
subplot(4,1,1);
plot(time_zcx(1:(end-wsp*50),cxno));
title(['CX Cell ', cxnost ' zoom 50x: ' paramline], 'Color', [.5 0 0], 'FontWeight', 'bold');
xlabel(['time in 20 us increments from ' st4 'ms to ' et4 'ms stimulating CX at ' stcxst 'ms and/or RE at ' strest 'ms']);
ylabel('mv');
if (stimcx >= startplot4) && (stimcx <= endplot4)
line([(stimcx-startplot4)*50 (stimcx-startplot4)*50], get(gca, 'YLim'), 'Color', 'g');
end
if (stimre >= startplot4) && (stimre <= endplot4)
line([(stimre-startplot4)*50 (stimre-startplot4)*50], get(gca, 'YLim'), 'Color', 'r');
end
subplot(4,1,2);
plot(time_zin(1:(end-wsp*50),inno)');
title(['IN Cell ', innost ' zoom 50x: ' paramline], 'Color', [.5 0 0], 'FontWeight', 'bold');
xlabel(['time in 20 us increments from ' st4 'ms to ' et4 'ms stimulating CX at ' stcxst 'ms and/or RE at ' strest 'ms']);
ylabel('mv');
if (stimcx >= startplot4) && (stimcx <= endplot4)
line([(stimcx-startplot4)*50 (stimcx-startplot4)*50], get(gca, 'YLim'), 'Color', 'g');
end
if (stimre >= startplot4) && (stimre <= endplot4)
line([(stimre-startplot4)*50 (stimre-startplot4)*50], get(gca, 'YLim'), 'Color', 'r');
end
subplot(4,1,3);
plot(time_ztc(1:(end-wsp*50),tcno)');
title(['TC Cell ', tcnost ' zoom 50x: ' paramline], 'Color', [.5 0 0], 'FontWeight', 'bold');
xlabel(['time in 20 us increments from ' st4 'ms to ' et4 'ms stimulating CX at ' stcxst 'ms and/or RE at ' strest 'ms']);
ylabel('mv');
if (stimcx >= startplot4) && (stimcx <= endplot4)
line([(stimcx-startplot4)*50 (stimcx-startplot4)*50], get(gca, 'YLim'), 'Color', 'g');
end
if (stimre >= startplot4) && (stimre <= endplot4)
line([(stimre-startplot4)*50 (stimre-startplot4)*50], get(gca, 'YLim'), 'Color', 'r');
end
subplot(4,1,4);
plot(time_zre(1:(end-wsp*50),reno)');
title(['RE Cell ', renost ' zoom 50x: ' paramline], 'Color', [.5 0 0], 'FontWeight', 'bold');
xlabel(['time in 20 us increments from ' st4 'ms to ' et4 'ms stimulating CX at ' stcxst 'ms and/or RE at ' strest 'ms']);
ylabel('mv');
if (stimcx >= startplot4) && (stimcx <= endplot4)
line([(stimcx-startplot4)*50 (stimcx-startplot4)*50], get(gca, 'YLim'), 'Color', 'g');
end
if (stimre >= startplot4) && (stimre <= endplot4)
line([(stimre-startplot4)*50 (stimre-startplot4)*50], get(gca, 'YLim'), 'Color', 'r');
end
hold off;
saveas(gcf,[fprefix '_sc_TR4.fig']);
saveas(gcf,[fprefix '_sc_TR4.png'], 'png');
saveas(gcf,[fprefix '_sc_TR4.eps'], 'eps');
end

Iniciar sesión para comentar.

Categorías

Más información sobre Polar Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by