Plotting date-times with date in top right corner instead of bottom right
조회 수: 3 (최근 30일)
이전 댓글 표시
When I plot some data against date-time values, the x-axis ticks contain only the times, and the bottom right hand corner contains the date. For example, in the MATLAB help page for plotting dates and durations, the very bottom plot the x-axis ticks are the months, and the bottom right hand corner shows the year. Is there a way to move the value at the bottom right hand corner to the top right hand corner, above the figure?
댓글 수: 2
Jan
2017년 12월 18일
Maybe it would be useful, if you mention which "in the MATLAB help page" you mean.
채택된 답변
Amy
2017년 12월 21일
편집: Amy
2017년 12월 21일
Hi Jonathan, there's this MATLAB answers post that you could refer to if you wanted to change the format of the x axis labels.
I'm not sure if there's a way to move just the secondary label to the top of the figure, but if you want to move all the x-axis labels to the top, after plotting your data, you could use the following commands:
ax = gca; ax.XAxisLocation = 'top';
If you're just moving that label from the bottom right corner to the top right corner, and you know nothing else in your figure is going to change, as a workaround you could do this: reassign the x tick labels, because this will hide the secondary label that automatically shows up. Then manually add a text box in the top right hand corner (or wherever you want it) by clicking on "Insert -> TextBox" in the figure window.
This command will hide the secondary x axis label:
xticklabels manual;
Note that this has a limitation that when you zoom or pan the plot, the tick labels will not update automatically.
댓글 수: 0
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!