Parrallel Coordinate Plot set tick label intepreter to LaTeX

5 visualizaciones (últimos 30 días)
Im looking to set the tick label intepreter of a parallelplot to by latex. I have found an existing solution but it does not seem to work in my MATLAB app:
However when I run the exact same code below it seems to work:
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}$'};
  2 comentarios
Adam Danz
Adam Danz el 1 de Feb. de 2024
What release of MATLAB are you using?
Isaiah
Isaiah el 2 de Feb. de 2024
Editada: Isaiah el 2 de Feb. de 2024
I am using R2023b.
I just tested the same code using the MATLAB script and it works so I will be creating on my plots there first. However the same code doesnt seem to work on a live script, although I am unsure of the reason for this.
Update:
Currently still experiencing weird outputs from the MATLAB script. When previewing the figure I am able to see the LaTeX interpreter, however once I save the image the figure reverts back to having no LaTeX interpreter.

Iniciar sesión para comentar.

Respuesta aceptada

Benjamin Kraus
Benjamin Kraus el 9 de Feb. de 2024
Editada: Benjamin Kraus el 13 de Feb. de 2024
As the warning states, by calling struct on the object, you are accessing the internal implementation details of the chart, and the behavior of those internal implementation details are not guaranteed to work in any particular way. What you are doing is not a documented feature, and is unlikely to work reliably or consistently, and could break at any moment.
That being said, I suspect the issue is how you are setting the labels themselves.
Try this instead:
data = randi(1,10,3);
p = parallelplot(data);
p.CoordinateTickLabels = {'$1^1$','$2\cdot2$','$\sqrt{3}$'};
drawnow
s = struct(p);
s.Axes.TickLabelInterpreter='latex';
Some details on why this may work (but is not guaranteed):
  • The parallelplot command creates a matlab.graphics.chart.ParallelCoordinatesPlot object.
  • The ParallelCoordinatesPlot is completely in control of the internal axes that is used as an implementation detail of that chart. As such, it can (and will) update any Axes properties whenever it feels it is appropriate. This may cause it to stomp on any property values you've set on the Axes directly.
  • When you set the TickLabelInterpreter property directly on the Axes, the ParallelCoordinatesPlot object has no way to know you did that. The same goes for the XTickLabel property. This means that (for example) if you save your figure and reopen the figure, any changes you've made to the Axes directly will be lost. It also means that none of this will work in the Live Editor (which leverages save/load internally).
  • At some later point, the ParallelCoordinatesPlot object is going to redraw itself. At that point, it can (and will) update whatever properties on the Axes it feels is appropriate to create the desired picture, causing you to potentially lose any values you've customized on the internal Axes.
  • This might mean that it changes the value of the TickLabelInterpreter property.
  • It definitely means it will change the value of the XTickLabel property.
What I suspect is causing the difference in behavior you are experiencing:
  • Because there is a property on the ParallelCoordinatesPlot object called CoordinateTickLabels, during the update of the ParallelCoordinatesPlot object, it is going to use the value of CoordinateTickLabels to replace the value of XTickLabel, stomping on any values you changed yourself.
  • This update could occur for many reasons, but one reason that is likely to cause an update to run on the ParallelCoordinatesPlot is resizing your figure (or resizing the App). So, when you resize the figure or App, there is a good chance that any customization you've made to the internal Axes will be lost.
  • Because there is a documented property on the ParallelCoordinatesPlot object called CoordinateTickLabels, you are much better off using that property (instead of Axis.XTickLabel) to change those labels. When you use CoordinateTickLabels, the ParallelCoordinatesPlot object will know about and correctly preserve the value across updates (and save/load).
  • Because there is no documented property on the ParallelCoordinatesPlot object for changing the interpreter, there is no documented way to change the interpreter. If you chose to go the undocumented route and update the Axes directly, it may or may not work the way you expect, but it also makes it less likely that the ParallelCoordinatesPlot object will stomp on your change, so it is more likely to work.

Más respuestas (0)

Categorías

Más información sobre Graphics Object Properties en Help Center y File Exchange.

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by