Advanced Plotting Toolkit

Showing results for 
Search instead for 
Did you mean: 

Center text in the Add Text function

I'm using the Add in order to add heat values to each tile on a tile plot but it does not look like there is any way to center the text (aline center for top/left). This is causing overflow of text between the tiles, see picture:


Does anyone know a solution for this (without decreasing text size) or if this functionality will be added to the Add

0 Kudos
Message 1 of 5

Are you adding that text as a single line or as individual items by specifying the X,Y coordinates?  It looks like your values aren't well aligned to any cell, which makes me think its all one string with spaces.  Have a look at how they implemented it here..



0 Kudos
Message 2 of 5

I'm using X, Y coordinates to specify the text for each cell. But I'm not sure you understood that this is in LabVIEW Advanced Plotting Toolkit or you meant that I should edit the Python files that the toolkit is using? I made an example vi to demonstrate the problem:





0 Kudos
Message 3 of 5

Matplotlib is the underlying plotting library that APT enables you to use in LabVIEW.  Matplotlib a python package, so in order to see if that functionality even exists in the underlying package, and could be supported in APT you will have to do some digging in the APT docs and possibly in python forums.  Then you could implement the fix by adjusting the APT code to your needs.   Note that the answer I linked to provides a few clues..


for y in range(data.shape[0]):
    for x in range(data.shape[1]):
        plt.text(x + 0.5, y + 0.5, '%.4f' % data[y, x],


 "horizontalalignment='centre'" suggest to me that there exists a native way in Matplotlib to do what you want.  Perhaps just adding a VI that is similar to Add but extends its features. See also -


But if your plots are as simple as your example then all you need to do is better define your x-offset to put the text in the right place.  This won't handle wrapping or exact centring but is a quick fix. 







0 Kudos
Message 4 of 5

The problem is that the APT python files is already compiled binaries in .pyd format. I looked at the source code for APT on GitHub: but it did not seem so trivial for me to fix and also to compile new .pyd files. Unfortunate the example I added was just to demonstrate the problem and the real usage needs it to be much more dynamic and that solution would not suffice.

0 Kudos
Message 5 of 5