Passing no of colours in colormap as a variable
Show older comments
Hi,
I am plotting several different contour plots in a code. The code for plotting them is below. My problem is that for publication purpose, I want to use 3500 colours instead of 500 (as shown below) since the figure then looks smooth. But obviously Matlab runs extremely slow on my Mac. I wanted to pass no. of colours as a variable and change it at one place. So that I don't need to change it at several places in the code. When I pass the variable e.g. noColors = 3500, Matlab complains at colormap jet() line saying it needs finite values. How to play around this problem?
contourf( a0Grid, omegaPGrid, log10(freqShift), 500, 'Edgecolor', 'none' )
colormap jet(500)
4 Comments
Image Analyst
on 19 Feb 2013
colormap jet(500) works fine for me.
Naveen
on 19 Feb 2013
Image Analyst
on 19 Feb 2013
But colormap(jet(noColors)) does? I didn't know that there would be a difference between the function call method and the command line method of calling colormap. It would be interesting to know the reason for that. I know there is a difference for some functions, like those that take a filename such as load() or save().
Walter Roberson
on 19 Feb 2013
colormap jet(500)
is equivalent to
colormap('jet(500)')
which is not a documented facility. It happens to work because colormap() feval()'s its argument when its argument is a string, but the documentation doesn't say that. The one example uses the function form equivalent to
colormap(jet(500))
which calls jet(500) and returns that numeric array as the argument to colormap()
Accepted Answer
More Answers (0)
Categories
Find more on Red in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!