MATLAB Answers


How do I create a color bar to correspond to my jet color scheme?

I've used the jet function to create a gradient of color, such that every color is a different voltage. How do I make a color bar given the RGB array I made with the jet function and assign the max and min voltage values on the color bar for my figure? Thanks!


Sign in to comment.

2 Answers

Answer by Chad Greene
on 13 Nov 2018
Edited by Chad Greene
on 13 Nov 2018
 Accepted Answer

Try this:
Plot some data:
Change the colormap*:
Add a colorbar and put a label on it:
cb = colorbar;
Set colorbar limits:
caxis([-8 4])
That'll create this figure:
* But note, there are some perceptual issues with using jet to represent numbers. For those reason's the jet colormap has fallen out of fashion in recent years. Read up on #endrainbow if you're curious to know more.


Show 1 older comment
It should work just as well for scatter plots as it does for the surface plot. Try this:
x = rand(100,1);
y = rand(100,1);
z = rand(100,1);
cb = colorbar;
caxis([0.2 0.8])
Please create a small synthetic dataset (say ten to twenty points) that is similar to your actual data and show the code you use to create your scatter plot using that synthetic dataset. After that describe specifically how the figure created by that code differs in appearance from the code you want. Perhaps with a concrete example we can run and use to experiment we can offer a suggestion on how to achieve or approach your goal.

Sign in to comment.

Answer by Image Analyst
on 13 Nov 2018

Use the caxis() function.

  1 Comment

Sign in to comment.