如何在颜色条刻度中添加数学符号 [英] How do you add math symbols in colorbar ticks

查看:159
本文介绍了如何在颜色条刻度中添加数学符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以将colorbar滴答声作为

figure;
hbar=colorbar;
ticks=get(hbar,'ytick');

现在如何将tick(end)的刻度标签设置为?

Now how do I set the tick labels at tick(end) to be ?

推荐答案

这很棘手.通常,对于轴标签和标题,您可以使用TeX或LaTeX格式,因为它们是文本对象,因此具有 'Interpreter'属性:

This is tricky. Normally, for axes labels and titles you can use TeX or LaTeX formatting since they are text objects and thus have an 'Interpreter' property:

xlabel('\infty');  %# Label the x axis with an infinity

但是,轴对象本身似乎没有对它们的 tick 标签使用Tex或LaTeX格式的方法.一种解决方案是从 MathWorks文件交换 e,它将用格式化的文本对象替换坐标轴刻度标签.

However, axes objects themselves don't appear to have a way to use Tex or LaTeX formatting for their tick labels. One solution is to download the submission Format Tick Labels from Alexander Hayes on the MathWorks File Exchange, which will replace the axes tick labels with formatted text objects.

另一种解决方案是更改 'FontName'属性 'Symbol'字体的轴坐标,其第165个 th 字符是无穷大符号.这是一个示例:

Another solution is to change the 'FontName' property of the axes to the 'Symbol' font, the 165th character of which is the infinity symbol. Here's an example:

hBar = colorbar;                           %# Create the colorbar
labels = cellstr(get(hBar,'YTickLabel'));  %# Get the current y-axis tick labels
labels{end} = char(165);                   %# Change the last tick label
set(hBar,'FontName','Symbol',...           %# Change the colorbar axes font
         'YTickLabel',labels);             %#   and update the tick labels

这是颜色栏的外观:

这篇关于如何在颜色条刻度中添加数学符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆