Changing Axis Bounds to correct units
조회 수: 3 (최근 30일)
이전 댓글 표시
Hello,
I am trying to change the bounds on the axis of some subplots. The number of datapoints is 80 so the horizontal axis reads 0-80. The axis should read -0.4 to 0.4 to accurately reflect the time before and after stimulation. I do not want anything else to change, just displaying the axis in seconds instead of the index of points. Would the best way to go about this be to make a new vector for the horizontal axis and plot with that?
Code and screenshot of figure below. Whatever advice you can offer would be very helpful. Thank you!
m = length(peth.rate(:,1));
% Group 1:
[peth] = getPETH_epochs(basepath,'basename',basename,'epochs',groups.one)
figure()
imagesc(peth.rate)
colormap('jet')
title('PETH Group1')
figure()
for i=1:m
subplot(4,6,i)
plot(peth.rate(i, :))
title(['Cell ', num2str(i)])
end
xlim([-0.4 0.4])
xlabel('Time From Stim') %change axis scale from 80 to +/- 0.4 s
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/896640/image.png)
댓글 수: 0
답변 (1개)
Benjamin Thompson
2022년 2월 16일
If you have a time vector, use it as the first argument to the plot function. For example:
>> t = 0:0.01:5;
>> x = 2*sin(2*pi*50/33*t);
>> figure, plot(t, x);
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Subplots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!