Is it somehow possible to update an existing candle-plot without redrawing the whole chart?
Meaning I want to add a candle when new data has arrived. Everytime redrawing the whole chart is rather slow.

 채택된 답변

Mario Malic
Mario Malic 2021년 1월 1일

0 개 추천

If you save the handle to the plot, you can access its Data property
h = candle(ax, someData)
h.Data(end+1) = [1 2 3 4];

댓글 수: 6

Ali Komai
Ali Komai 2021년 1월 1일
This is what I tried but it doesn't work this way. The candle function doesn't return a handle with a data property but just an array of class matlab.graphics.primitive.Data. These object have a XData and a YData property but this is no OHLC but the coordinates of the candle body if I understand what I see.
I see no straight forward way of adding to this data.
I have taken a look at candle
load SimulatedStock.mat;
candle(TMW(end-20:end,:),'b');
title('Candlestick chart for TMW')
ax = gca;
ax.Children
If you take a look at children of axes, there are patches and one line object. Patches form these filled or empty rectangles and lines are the vertical line for each patch object. So if you want to add a new data, you'd have to add a patch object and modify the line object.
Ali Komai
Ali Komai 2021년 1월 1일
Yes, I understood that. I just hoped there was a more convenient way
Actually, my bad, solution is as simple as this.
load SimulatedStock.mat;
candle(TMW(end-20:end-2,:),'b');
title('Candlestick chart for TMW')
hold on
candle(TMW(end-1:end,:),'b');
Ali Komai
Ali Komai 2021년 1월 2일
Ah I see, the candle is appended automatically at the end. Probably works through the included datetime. Nice!
Thank you very much!
Mario Malic
Mario Malic 2021년 1월 2일
편집: Mario Malic 2021년 1월 2일
You're welcome. You can accept my answer on the blue button, thanks in advance.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

태그

질문:

2021년 1월 1일

편집:

2021년 1월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by