MATLAB: How to add a diagonal gradient and corresponding colorbar to a plot colorbargradientMATLABplot This is what I'd like to create with my own data, how can I add that gradient and colorbar to my plot Best Answer An example:[X,Y] = meshgrid(1:0.1:3);Z = X+Y;pcolor(X,Y,Z)shading interpcolorbar('Location','NorthOutside')You can also create your own colormap Related SolutionsMATLAB: How to create a colormap for a flat plane Use something like this:surf(x,y,z-1,x+0.5*y),shading flatYou can use whichever linear combination of x and y to have your gradient in your desired direction.HTH MATLAB: Change diagonal place a= magic(3)a = 8 1 6 3 5 7 4 9 2>> b=a;>> for i =2:size(a,1)b(i,1:i)= fliplr(a(i,1:i));endbb = 8 1 6 5 3 7 2 9 4 Related QuestionExtracting matrix diagonal with diag(A)How can i plot a colormap (2d)Colorbar
Best Answer