Surfl chart; datetime on y-axis, letters on x-axis

조회 수: 1 (최근 30일)
Steven Niggebrugge
Steven Niggebrugge 2017년 2월 10일
답변: Peter Perkins 2017년 2월 13일
Hi, i am trying to make a 3d surface chart (surfl) out of a x-by-y table named 'cum_pl', which contains daily P&L numbers for x days and for (y-1) markets. The table contains dates of DateTime type in the first column (column header = 'Date'). The table contains the Ticker symbols in the header row (cum_pl.Properties.VariableNames). The rest of the matrix contains the daily P&L for each market, for each day.
I use surfl(cum_pl{:, 2:end}) to initially plot the P&L figures in a surface chart. However, i can't seem to manage to show the datetimes on the y-axis (e.g.,format 'dd-mm-yy'), and the tickers on the x-axis, using the YTick, YTickLabel properties of the gca object.
See a small picture of the cum_pl table attached. I am using Matlab 2016a.
Hope someone can help out, thanks in advance!
Steven

채택된 답변

Peter Perkins
Peter Perkins 2017년 2월 13일
surf supports datetime in R2016b, but not in R2016a.
In 16a, you can convert datetimes to datenums and use datetick, or you can set the tick locations yourself and assign the labels by converting the datetime to text using cellstr.
Hope this helps.

추가 답변 (1개)

dpb
dpb 2017년 2월 10일
Be simpler if you'd attach a subset of the data itself but you've got to give the X, Y axes values to plot against to get dates. I've no idea if surfl is datetime-aware or not, but give it a go and see...
surfl(cum_pl{:,1},[1:size(cum_pl,2),cum_pl{:, 2:end})
Then use 'yticklabel' property to set the ticker symbols. I'd guess you're going to run out of room to display all the symbols for every column, though...

카테고리

Help CenterFile Exchange에서 Grid Lines, Tick Values, and Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by