1

I want to add a color dimension to my plot in matlab, based on values 0:100 and a colorscale.

How exaclty do I do this?

I know with scatter you can add a color dimension - but then the lines cannot be connected. I know with plot you can add one color, but not for every point.

x=1:100;
y=randi(100,1);
c=fliplr(1:100);
plot_with_color(x,y,c) %what is this function?

Thank you, I just couldn't find this with google

user2305193
  • 2,079
  • 18
  • 39
  • 1
    Please edit the question if you think the duplicate does not match and I will undo it! I understood that is what you wanted, so I closed it so you have the answer that you want ;) – Ander Biguri Aug 25 '20 at 14:01
  • 1
    apparently there really is **no** easy way to do this. This is a bit crazy, but ok Mathworks... thanks for being kind/friendly @AnderBiguri – user2305193 Aug 25 '20 at 14:49
  • Definetly not a trivial way of doing it no! But hey, this is how we become better coders, isnt it? :D Good luck! – Ander Biguri Aug 25 '20 at 14:57
  • 1
    for reference/anyone stumbling upon this and also in need for a quick and dirty solution: I ended up using `scatter(x,y,20,c)` (`c` is the color dimension here) with a lot of points / very zoomed out. This is very silly, but it will give you something resembling a nice line, especially if you plot the 'dots' a bit larger. – user2305193 Aug 26 '20 at 15:15

0 Answers0