JB Gastineau
JB Gastineau

Reputation: 1

How to print comments at the right side of a matlab graph?

I want to plot only one simple set of data. For example, my plot command could be :

x = (1:10);
y = ones[1,10];
plot(x,y);

In fact, the y data set could have been generated by a previous code, depending on several parameters. I want to print the name of every parameters and there values outside the graph, at the right of it, as if it were a legend. My problem is that I have several parameters to print, but only one set of data.

I tried to do this by the text or legend functions, but it never fit completly my needs. Could you help me please ?

Upvotes: 0

Views: 568

Answers (1)

gchadwick
gchadwick

Reputation: 111

I think this code should help you out. Its probably easiest to split your figure into two axes, the right one just to hold text:

x = rand(1,10);
y = rand(1,10);
figure  % makes your figure
axes('Position', [0.05,0.05,0.45,.9]) % makes axes on left side of your figure
scatter(x,y)
axes('Position', [0.55,0,1,1],'ytick',[],'xtick',[]) %make axes on left side of your figure, turns of ticks
text(0.05,0.85,{'Parameter 1: blah blah';'Parameter 2: bloop bloop';'Parameter 3: ....'},'Interpreter','Latex')

Play around with the numbers in the brackets to resize things as you like.

Upvotes: 1

Related Questions