MATLAB 绘制 K 线图

需要安装 Financial Toolbox

% 示例数据
openPrices  = [100, 102, 104, 103, 105];
highPrices  = [105, 107, 106, 108, 109];
lowPrices   = [99, 101, 103, 102, 104];
closePrices = [104, 105, 103, 107, 108];

data = [openPrices', highPrices', lowPrices', closePrices'];

% 创建一个新的图形窗口
figure;

% 绘制 K 线图
candlestick = candle(data);
dateaxis('x', 2, datetime(2023,1,1)) % 将序列-日期轴标签转换为日历-日期轴标签

% 设置图表属性
title('K Line Chart');
xlabel('Date');
ylabel('Price');
grid on;

image

参考:

posted @ 2024-06-19 01:45  Undefined443  阅读(1)  评论(0编辑  收藏  举报