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

3 views (last 30 days)
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_sin = sin(t);
plot(app.ax4,t,t_sin, '-ro', 'DisplayName','sin(t)');
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')
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;
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

Accepted Answer

Eric Delgado
Eric Delgado on 26 Sep 2022
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...
galaxy on 26 Sep 2022
Thank you for your idea.
Yes, I think slider does not beautiful too :)). But it is seem the best way to me now.

Sign in to comment.

More Answers (0)




Community Treasure Hunt

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

Start Hunting!

Translated by