I am using parallelplot to generate some plots. However, when I used:
set(gca,'TickLabelInterpreter','latex');
I get:
Unrecognized property TickLabelInterpreter for class ParallelCoordinatesPlot.
Is there any alternative to set the x and y labels of my plot to latex style?
Example:
data = randi(1,10,3);
p = parallelplot(data)
p.CoordinateTickLabels = {'one','two','three'};
set(p,'TickLabelInterpreter','latex');

댓글 수: 5

Adam Danz
Adam Danz 2023년 3월 11일
> Is there any alternative to set the x and y labels of my plot to latex style?
This solution isn't ideal and doesn't direclty address your goal.
If you're using MATLAB R2022a or later, you could use the fontname function to set the font for the entire figure generated by parallelplot, not just the tick labels. You'll also need the font used by latex (see How can I add a new font).
Rub Ron
Rub Ron 2023년 3월 12일
@Adam Danz thanks, seesm it is the only option. What I am not sure which font resembles the one nomrally a latex interpreter wpuld use, crm8, msam8, cmss10, cmr10?
Adam Danz
Adam Danz 2023년 3월 12일
Good question. I found this answer that points to cmr12 but I haven't tried it. You can also add fonts to your system that should show up in MATLAB. See the listfonts list after a MATLAB restart.
Rub Ron
Rub Ron 2023년 4월 14일
@Adam Danz, Hi, I try to use the answer of @LR_eng, converting the parallel plot into a struct variable. It works for the XTickLabel, but then when I try to save the figure it go back to the previous ticks. You suggested here to use:
S.AutoListeners__{1}.Enabled = false
However, even using it, the figure go backs to the previous ticks. May you have any suggestion? Thanks in advance for your time.
Adam Danz
Adam Danz 2023년 4월 14일
I wrote that solution prior to working at MathWorks. It uses undocumented features that aren't intended to be use-facing. The problem with using undocumented features is that they may not behave as one may expect and there is no guarantee that they will be supported in the future. We will consider adding an intepreter property that can be used with parallelplot.

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

 채택된 답변

LR_eng
LR_eng 2023년 3월 13일
편집: LR_eng 2023년 3월 13일

1 개 추천

I just had the same problem. Just changing the font did not help me. Apparently, one workaround is to convert the parallelplot object to a struct like it was done here. This worked for me and that way you can also nicely access all the other useful properties. However, it produces a warning that it is not recommended to do it like that.
data = randi(1,10,3);
p = parallelplot(data);
S=struct(p);
Warning: Calling STRUCT on an object prevents the object from hiding its implementation details and should thus be avoided. Use DISP or DISPLAY to see the visible public details of an object. See 'help struct' for more information.
S.Axes.TickLabelInterpreter='latex';
S.Axes.XTickLabel = {'$1^1$','$2\cdot2$','$\sqrt{3}$'};

댓글 수: 4

Rub Ron
Rub Ron 2023년 3월 13일
Hi, I tried and it worked but only for the ticklabels, but the rest dont change the style to latex. For the rest I tried: S.Axes.TextInterpreter='latex'; S.Axes.LegendInterpreter='latex';
Sorry I did not see that you also need the ticks on the y axis. Maybe you can try the following:
S.YRulers(1).TickLabelInterpreter='latex'
S.YRulers(2).TickLabelInterpreter='latex'
S.YRulers(3).TickLabelInterpreter='latex'
Rub Ron
Rub Ron 2023년 3월 14일
Thanks, but still, what about the x and y labels and the legend
Benjamin Kraus
Benjamin Kraus 2024년 2월 13일
If you are using this approach, just be aware that it is undocumented and not all aspects are guaranteed to work. I've added some additional context over on this other question on the topic, but one huge caveat is that any changes you make to the axes directly won't survive save/load and are unlikely to work in the Live Editor.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

질문:

2023년 3월 11일

댓글:

2024년 2월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by