Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Update:</strong> The following appears to have broken for newer versions (R2015a and newer?), and there is currently no workaround to change the interpreter for data tip text.</p> <hr> <p>For some odd reason, the <a href="https://www.mathworks.com/help/matlab/ref/datacursormode.html" rel="nofollow noreferrer">data cursor tool</a> in MATLAB forcibly sets the data tip text to be displayed literally instead of with TeX/LaTeX interpreting (even if the <a href="https://www.mathworks.com/help/matlab/ref/text-properties.html#property_d0e1002285" rel="nofollow noreferrer">default MATLAB settings</a> say to do so). There also appears to be no way of directly setting text properties via the data cursor mode object properties.</p> <p>However, I've figured out one workaround. If you add the following to the end of your <code>polarlabel</code> function, the text should display properly:</p> <pre><code>set(0,'ShowHiddenHandles','on'); % Show hidden handles hText = findobj('Type','text','Tag','DataTipMarker'); % Find the data tip text set(0,'ShowHiddenHandles','off'); % Hide handles again set(hText,'Interpreter','tex'); % Change the interpreter </code></pre> <h2>Explanation</h2> <p>Every graphics object created in the figure has to have a <a href="https://www.mathworks.com/help/matlab/learn_matlab/understanding-handle-graphics-objects.html" rel="nofollow noreferrer">handle</a>. Objects sometimes have their <a href="https://www.mathworks.com/help/matlab/ref/text-properties.html#property_d0e1005510" rel="nofollow noreferrer"><code>'HandleVisibility'</code> property</a> set to <code>'off'</code>, so their handles won't show up in the list of child objects for their parent object, thus making them harder to find. One way around this is to set the <a href="https://www.mathworks.com/help/matlab/ref/root-properties.html#property_d0e877586" rel="nofollow noreferrer"><code>'ShowHiddenHandles'</code> property</a> of the <a href="https://www.mathworks.com/help/matlab/ref/groot.html" rel="nofollow noreferrer">root object</a> to <code>'on'</code>. This will then allow you to use <a href="https://www.mathworks.com/help/matlab/ref/findobj.html" rel="nofollow noreferrer"><code>findobj</code></a> to find the handles of graphics objects with certain properties. (<strong>Note:</strong> You could also use <a href="https://www.mathworks.com/help/matlab/ref/findall.html" rel="nofollow noreferrer"><code>findall</code></a> and not worry about the <code>'ShowHiddenHandles'</code> setting)</p> <p>Turning on <a href="https://www.mathworks.com/help/matlab/ref/datacursormode.html" rel="nofollow noreferrer">data cursor mode</a> and clicking the plot creates an <a href="https://www.mathworks.com/help/matlab/ref/hggroup.html" rel="nofollow noreferrer">hggroup object</a>, one child of which is the <a href="https://www.mathworks.com/help/matlab/ref/text.html" rel="nofollow noreferrer">text object</a> for the text that is displayed. The above code finds this text object and changes the <a href="https://www.mathworks.com/help/matlab/ref/text-properties.html#property_d0e1002285" rel="nofollow noreferrer"><code>'Interpreter'</code> property</a> to <code>'tex'</code> so that the theta symbol is correctly displayed. </p> <p>Technically, the above code only has to be called once, not every time <code>polarlabel</code> is called. However, the text object doesn't exist until the first time you click on the plot to bring up the data tip (i.e. the first time <code>polarlabel</code> gets called), so the code has to go in the <code>UpdateFcn</code> for the data cursor mode object so that the first data tip displayed has the right text formatting.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload