Multi-colored tick labels in bold, redux

3 visualizaciones (últimos 30 días)
Leo Simon
Leo Simon el 17 de Abr. de 2020
Editada: KSSV el 18 de Mzo. de 2021
From this thread I learned from @Tommy how to create individually colored tick labels, using the Label function defined in the code below. In this thread, @JanSimon says how to create bold face tick labels. But this suggestion doesn't seem to work. If you run this code to the keyboard, you'll see the colored tick labels, but they are in a very wishywashy pallette. I'm hoping that switching to bold face might help, but when I `dbcont` to the next line, the labels disappear. I thought the problem maybe related to needing two backslashes in front of the lambda 's but that doesn't help either. Could somebody please explain what I'm doing wrong? Thanks very much
n = 4;
C = [ ...
0.5142 0.7695 0.7258 ;
0.9300 0.8644 0.4048 ;
0.6929 0.6784 0.7951 ;
0.9154 0.4668 0.4158 ;
0.9227 0.6565 0.3574 ;
0.6528 0.8096 0.3829 ;
0.6856 0.4668 0.6893 ;
0.7914 0.7914 0.7914 ;
0.9191 0.7476 0.8352 ];
Label = @(ii,s) sprintf('\\color[rgb]{%f, %f, %f}%s', C(ii,:), s);
Y = sort(rand(n,n));
h = plot(1:n,Y);
for ii=1:n;
h(ii).Color=C(ii,:);
end
set(gca,'XTick',1:n);
legend
for ii=1:n
XTickLabel{ii} = Label(ii,['\lambda_' num2str(ii)]);
end
set(gca,'XTickLabel',XTickLabel);
axesH = gca;
axesH.XAxis.TickLabelFormat = '\\textbf{%g}';
keyboard;
axesH.XAxis.TickLabelInterpreter = 'latex'

Respuesta aceptada

dpb
dpb el 18 de Abr. de 2020
Looks mostly to be the choices for the rgb triplets aren't very distinctive, but a contributing factor is there just aren't many pixels set.
You don't need anything fancy to set bold font, just modify the Label function:
Label = @(ii,s) sprintf('\\color[rgb]{%0.3f, %0.3f, %0.3f}\\bf%s', C(ii,:), s);
This is all standard TeX, w/ the TextInterpreter stuff you needs must escape any LaTeX with $$ and, of course, when you turn it on, all the standard TeX stuff goes south. You can't mix the two...
  4 comentarios
Leo Simon
Leo Simon el 18 de Abr. de 2020
Increasing the font size certainly does help. I didn't think I had any font choices for math symbols?
dpb
dpb el 18 de Abr. de 2020
I honestly don't know if there are different renditions of greek symbols with changing fontname or not...I've never explored in depth to know.

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by