How do I plot a date along the x-axis?

Hi! I have 2 sets of data that shows temperature over a long period of time. I am trying to plot a graph with dates along the x-axis.
I have shortened the data as my original table has hundreds of points, but one is a table formatted like this:
Country M/DD/YY M/DD/YY M/DD/YY
---------- ------- ------ ------
{CountryA} 15 18 20
{CountryB} 17 22 25
{CountryC} 16 19 22
where the date is formatted in the table's column variable.
Another is a table like this:
Date Temperature
----- -----------
{'M/DD/YY'} 20
{'M/DD/YY'} 22
{'M/DD/YY'} 24
where the date is formatted inside a cell in the first column of a table.
I'm assuming it has something to do with the x-ticks and datetime functions, but I can't seem to get my 'start' point as my first date and my last point as the last point in my data. As this is being updated daily, this last point keeps changing.

 采纳的回答

Cris LaPierre
Cris LaPierre 2020-11-12
I would suggest taking table 1 and transposing it so that your countries are your column headers, and dates are all in a column.
Convert all dates to datetimes.
Then just plot as you normally would with your dates as the X values. They will appear as datetimes in the plot.
If you want to adjust the display format, use xtickformat.

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Calendar 的更多信息

产品

版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by