Reputation: 21180
In Matlab, the following generates a black color on the specified line in the legend:
leftAxis = sprintf('left y-axis','Color','r');
leg = legend([.. bla bla ..], sprintf('test [%s]', leftAxis), etc... );
What I'm trying to achieve is two colors on the same line in the legend. (so in this example the part 'test' should be black and the part 'left y-axis' should be red.
What I've tried:
A picture to visualise what I mean:
Upvotes: 4
Views: 1797
Reputation: 21561
I am going to be blunt and guess that you made a mistake.
Here we can see that latex should work in figure labels.
And here we can see that matlab should allow using colors with latex.
Unfortunately I don't have the chance to try it out now, but I would guess this is the way to go. If it fails, please show what code you used.
Upvotes: 3
Reputation: 2557
Probably you mistyped tex string:
figure
hold on
line1H=plot(1:10,1:10);
line2H=plot(1:10,2*(1:10),'r');
leg{1} = 'BlackText {\color{blue}line1} BlackAgain';
leg{2} = 'BlackText {\color{red}line2} BlackAgain';
legend([line1H,line2H],leg{:})
Generates:
Upvotes: 6