How to draw line logarithmic x axis and y axis
이전 댓글 표시
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
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
2020년 9월 7일
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
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
2020년 9월 13일
Adam Danz
2020년 9월 14일
See my answer below.
답변 (2개)
Mario Malic
2020년 9월 7일
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에서 Time Series Objects에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!