matlab:将带圆圈的数字放在图形上 [英] matlab: putting a circled number onto a graph
问题描述
我想在图表上放置一个带圆圈的数字作为标记靠近(但不是在)一个点.听起来很简单,但我也想保持缩放/纵横比不变.
I want to put a circled number on a graph as a marker near (but not on) a point. Sounds easy, but I also want to be invariant of zoom/aspect ratio changes.
由于这个不变量,我不能将圆绘制为线对象(在重新缩放时不重新绘制);如果我使用圆形标记,则必须在重新缩放时调整其偏移量.
Because of this invariant, I can't draw a circle as a line object (without redrawing it upon rescale); if I use a circle marker, I'd have to adjust its offset upon rescale.
我能想到的最简单的方法是使用 Unicode 或 Wingdings 字符 ①②③等在 text()
函数的字符串中.但是 unicode 似乎不能正常工作,以下示例仅适用于 ①而不是其他数字(产生矩形框):
The simplest approach I can think of is to use the Unicode or Wingdings characters ① ② ③ etc. in a string for the text()
function. But unicode doesn't seem to work right, and the following sample only works with ① and not for the other numbers (which yield rectangle boxes):
作品:
clf; text(0.5,0.5,char(129),'FontName','WingDings')
不起作用(应该是圈出的2):
doesn't work (should be a circled 2):
clf; text(0.5,0.5,char(130),'FontName','WingDings')
什么给出了,谁能建议一个解决方法?
What gives, and can anyone suggest a workaround?
推荐答案
这似乎对我有用,使用 Matlab 的 Latex 解释器,并且 \textcircled
:
This seems to work for me, uses Matlab's latex interpreter, and \textcircled
:
clf; text(0.5, 0.5, '$\textcircled{2}$', 'Interpreter', 'latex')
\textcircled
命令似乎有一些 偏移问题,也许您可以尝试改进使用的latex命令并告诉我们:)
The \textcircled
command seems have some offset problems, maybe you can try to improve the used latex command and let us know :)
例如,按照上面的链接,我得到了更好的结果:
Following the above link, for example, I get better results with:
clf; text(0.5, 0.5, '$\raisebox{.5pt}{\textcircled{\raisebox{-.9pt} {2}}}$', 'Interpreter', 'latex')
不过,两位数看起来还是很糟糕.
Still, two digit numbers look awful.
这篇关于matlab:将带圆圈的数字放在图形上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!