Plotted text changes size when its transfered to another figure

I am developing an AppDesigner app that tries to automate some predefined vector drawings using UI axes. I basically have some number of boxes that I have created using polyshape and they have numbers in the middle created by using text function. However, since I have to use release 2019a, I cannot directly save uiaxes as a vector pdf, so I use a workaround that I found in community about copying all the child objects of this axes in a new invisible figure and saving that figure. However, when I copy axes childs to this figure the text size changes drastically and since I have a short but wide plot the text comes quite large in comparision with the boxes which makes exported vector unusable. Is ther any way for me to change the fontsize in this plotted text after I copied it to new figure?
As an alternative way, the toolbar in the uiaxes has an export button that works really good to export vector graphics, is there a programmatic way to activate the callback of toolbar export button? Since exportgraphics doesn't work in 2019a I couldn't able to find a way to save figures that works similarly to the export button, I am using saveas but it saves the figure in a aspect ratio that doesn't include all the data in the figure.

4 commentaires

Hi, Tek,
As you seem familiar with using the objects:
Have you tried to check and possibly change the "FontSize"-property of the text objects?
See "Name-Value Arguments" of the text-function:
Best regards
Gunnar
Hello Gunnar,
Yes, I have set the font size that is suitable for the uiaxes. However, after I copy these objects to a new figure handle (to be able to save them as a vector pdf), even I could able to find all graphic text objects using findall function, I couldn't able to change it via using set function. (Set property of object - MATLAB set (mathworks.com)) Since the number of total text objects in the graph changes with the number of boxes and there may be some other texts in the graph that I don't want to change size, I need to find a programatic way to identify text objects via strings and set FontSize.
Gunnar Zindel
Gunnar Zindel le 13 Oct 2023
Modifié(e) : Gunnar Zindel le 13 Oct 2023
Hi, Tek,
so, if you have the need to identify specific text objects, you might think about giving them tags using the tag property, which a text object should have if i remember that right.
You could for example tag them all as "NeedsResize" or something else before saving them and then after reloading them find the correct ones using the "findobj" - function.
Best regards
Gunnar
Hello Gunnar,
Yes I guess tagging them, then reloading can work but at this point, I think it will be easier to call the function that create the graph again for the new figure, it basically does the same thing minus idetification of which text needs to be resized.
Also, I am trying to get a zoomable text in my uiaxes since I have a shape that is very wide but very short (like 240 unit wide but only 20 unit tall), and when the graph shows all the objects having a big text is not meaningful. However, when user zooms in I want to text to be visible. I have successfully modified TextZoomable(x,y,varargin) - File Exchange - MATLAB Central (mathworks.com) that code to work with uiaxes however, my listener that listen change in Xlim and Ylim limits (to capture that is user zoomed and what is the zoom ratio) is called 5760 times while user only tried to zoom for 12 times (validateAndSetLimits funtion is only called 12 times). Profiler shows the line ax.Xlim = sort(new_xlim) line in Profiler changed the Xlim 240 times for each call of the validateAndSetLimits funtion (which is the number how many text objects are present in the graph). Since I also update textsize for each change in the Xlim set handles function is called 1382400 times which took 90 seconds to execute for 12 zoom operations (115200 times for each zoom) which makes this function very slow. Do you have any suggestion to improve performance of this funtion?

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange

Produits

Version

R2019a

Question posée :

Tek
le 12 Oct 2023

Commenté :

Tek
le 16 Oct 2023

Community Treasure Hunt

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

Start Hunting!

Translated by