0

I want to create a plot of 2D data that is generated using different parameters. Something like this:

figure;
hold on;
parameters = [1:10];
for param = parameters;
  x = [1:10];
  y = ones(10) * param;
  plot(x, y);
endfor
hold off;

Instead of cluttering the graph with a legend (the range of param might become large, and then it would look similar to plotting color codded graph in matlab), I'd like to add a color map to the right of the graph. Something similar to this: gnuplot linecolor variable in matplotlib? How do I do this?

I found the "colorbar" command, but that only visualizes the range [0:1] of the current color map. The "caxis" command can help then. See also: http://cresspahl.blogspot.de/2012/04/octave-quickies-customizing-colorbar.html

Community
  • 1
  • 1
milianw
  • 5,164
  • 2
  • 37
  • 41

1 Answers1

0

Sorry, found the answer myself:

figure;
hold on;
parameters = [1:10];
for param = parameters;
  x = [1:10];
  y = ones(10) * param;
  plot(x, y);
endfor
colorbar();
caxis([min(parameters), max(parameters)]);
hold off;

Also note that the gnuplot graphics toolkit doesn't work well with such a plot (zooming etc. breaks the plot). If you instead use the flkt toolkit, it works nicely though.

milianw
  • 5,164
  • 2
  • 37
  • 41