
How can I use html in UItable for draw line??
조회 수: 5 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
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
Eric Delgado
2022년 9월 26일
I think a slider could be a solution. Not as beautiful as controlling directly the panel, but...
% Value changing function: Slider
function SliderValueChanging(app, event)
x1 = (event.Value+1)/2;
x2 = 1-x1;
app.GridLayout.ColumnWidth(1:2) = {sprintf('%fx', x1), sprintf('%fx', x2)};
end
You could get something like this... (see attached app made in R2021b)

추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
