简体   繁体   中英

Time on y axis - Matlab

I have plotted a figure with imagesc. The data was extracted from a file and the time was readed as a string column so I converted to double with datenum.

  time = datenum(time, 'HH:MM:SS');

  figure(1)
  imagesc(freq,time,rssimat);
  colorbar;

In this way it works but the picture looks like this

在此处输入图片说明

As you notice the y axis has this double numbers which represent the time converted with datenum. I actually would like to see my actual time like 'HH:MM:SS'. Therefore I added a line:

  datetick('y', 'HH:MM:SS');

And now my figure looks like... 在此处输入图片说明

It seems like you need to "zoom in" on Y axis. Your tracked interval appears to be very short in duration while on the Y axis you display the whole day.

Did you try: datetick('y', 'HH:MM:SS', 'keeplimits'); ? This will basically zoom in and fill the entire chart, while on the Y axis you will have HH:MM:SS format.

If you use datetick('y', 'HH:MM:SS', 'keepticks'); it will preserve the locations of the ticks while converting the labels to HH:MM:SS format.

您可以在Matlab中使用ylim函数来限制y范围

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM