Hi All,
I have some financial data price and time.
I need to plot it on a chart, however, i want the Y axis to be a log scale and the x axis to be a log scale
so both need to be log scaled.
How can i do this?

6 件のコメント

Star Strider
Star Strider 2020 年 9 月 7 日
編集済み: Star Strider 2020 年 9 月 7 日
Dates and times, even when using datetick, are apparently not possible with logarithmic scales. I already did that experiment.
That may not make any sense anyway, unless it is with respect to a particular date, so essentially ‘date-refdate+1’, or something similar.
Rizwan Khan
Rizwan Khan 2020 年 9 月 7 日
It will be respect to the starting date of the instrument, when the instrument floated.
were you able to plot it, i have errors when trying to even plot the date on x-axis?
Star Strider
Star Strider 2020 年 9 月 8 日
The problem with that approach is that then the dates do not make any sense. I woiuld just use semilogy and be done with it.
Adam Danz
Adam Danz 2020 年 9 月 13 日
Convert the dates to duration from the starting date but use the numeric form of the durations (ie, not the "duration' class). Then you're just working with regular old numbers that can sustain the log scale.
Rizwan Khan
Rizwan Khan 2020 年 9 月 13 日
@Adam - Can you expand a little further on what your suggesting, i didn't quite understand you
Adam Danz
Adam Danz 2020 年 9 月 14 日
See my answer below.

サインインしてコメントする。

回答 (2 件)

Mario Malic
Mario Malic 2020 年 9 月 7 日

0 投票

3 件のコメント

Rizwan Khan
Rizwan Khan 2020 年 9 月 7 日
When i have my time data (t) in the format below it won't allow me to plot it
I can chage the data format using dateNumber = datenum(t), but i don't want to, i want to read the x-axis as a normal time
So how can i plot time data like the below on the x-axis?
25-Aug-2020 17:30:55
26-Aug-2020 17:30:55
27-Aug-2020 17:30:55
28-Aug-2020 17:30:55
31-Aug-2020 17:30:55
01-Sep-2020 17:30:55
02-Sep-2020 17:30:55
03-Sep-2020 17:30:55
04-Sep-2020 17:30:55
Rizwan Khan
Rizwan Khan 2020 年 9 月 7 日
This is the error i get when using loglog or even plot with the time data format above
It wants a numeric
Error using loglog
Data inputs must match the axis configuration. A numeric axis must have numeric data inputs or data inputs which can be converted to double.
Rizwan Khan
Rizwan Khan 2020 年 9 月 7 日
I tried using xtickformat('yyyy-MM');
However, i then get the error that this time format does not support log scale?
The coordinate system or ruler class does not support log axis scale.

サインインしてコメントする。

Adam Danz
Adam Danz 2020 年 9 月 14 日
編集済み: Adam Danz 2020 年 9 月 14 日

0 投票

Convert the dates to duration from the starting date but use the numeric form of the durations (ie, not the "duration' class). Then you're just working with regular old numbers that can sustain the log scale.
If you want to see the date for each point, add the dates to the datatips.
Demo:
% Create date-time vector and data
dt = datetime(2020,1,1) + days(0:5:365);
data = exp(1:numel(dt));
% Compute number of days since the start of dt.
ndays = days(dt - dt(1));
% Plot data and show starting date in xlabel
h = loglog(ndays,data, 'o');
xlabel(sprintf('Number of days since %s',datestr(dt(1))))
% Now add the dates to each marker in their datatip.
h.DataTipTemplate.DataTipRows(end+1) = dataTipTextRow('Date',dt);
X is the number of days since the first datetime value.
Date shows the datatime value for each data point.

カテゴリ

ヘルプ センター および File Exchange で Dates and Time についてさらに検索

製品

リリース

R2020a

質問済み:

2020 年 9 月 7 日

コメント済み:

2020 年 9 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by