How can I use html in UItable for draw line??

3 ビュー (過去 30 日間)
galaxy
galaxy 2022 年 9 月 26 日
コメント済み: galaxy 2022 年 9 月 26 日
Hi all,
I want to instead line legend by table.
Following is example.
app.Panel_3.AutoResizeChildren = 'off';
app.ax4 = subplot(1,1,1,'Parent',app.Panel_3);
t=-10:1:10;
t_sin = sin(t);
plot(app.ax4,t,t_sin, '-ro', 'DisplayName','sin(t)');
hold(app.ax4,"on");
plot(app.ax4,t,tan(t), '-bo', 'DisplayName','tan(t)');
app.UITable.ColumnName = {'Line', 'Name', 'Check'};
%% Get all line of app.ax3
ax4_allLines = findobj(app.ax4, 'type', 'line');
ax4_allLinesName = {};
for id = 1:length(ax4_allLines)
linecolor = rgb2hex(ax4_allLines(id).Color);
marker = ax4_allLines(id).Marker;
if strcmp(marker,'none')
marker=[];
end
linestyle = ax4_allLines(id).LineStyle;
ax4_allLinesName{end+1, 1} = ['<hr style="height:2px;border-width:0;color: ' linecolor '">'];
ax4_allLinesName{end, 2} = ax4_allLines(id).DisplayName;
ax4_allLinesName{end, 3} = true;
end
app.UITable.Data = ax4_allLinesName;
% s = uistyle("Interpreter","html");
% addStyle(app.UITable,s);
you can see that, when I tried to use HTML to draw line, it couldn't.
My expect.
Or has marker is excilent.
Do anyone have idea? Could you give me.
Thank you so much

採用された回答

Eric Delgado
Eric Delgado 2022 年 9 月 26 日
uitable doesn't have a html interpreter. So... below is my approach to this issue.
app.UITable.Data = table(["–––––o–––––"; "–––––o–––––"], ["tan(t)"; "sin(t)"], [true; true]);
s1 = uistyle('FontColor','b', 'HorizontalAlignment', 'center', 'FontWeight', 'bold');
s2 = uistyle('FontColor','r', 'HorizontalAlignment', 'center', 'FontWeight', 'bold');
addStyle(app.UITable, s1, "cell", [1,1])
addStyle(app.UITable, s2, "cell", [2,1])
You will get...
  4 件のコメント
galaxy
galaxy 2022 年 9 月 26 日
Thank you for your idea.
Yes, I think slider does not beautiful too :)). But it is seem the best way to me now.

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

その他の回答 (0 件)

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by