How to scale colors in a surface plot?
20 views (last 30 days)
Show older comments
I am trying to generate a surface plot of Z values which are spaced very closely. I want to increase the contrast between neighboring cells on the surface plot for better visualization. What caxis/cdata properties should I use to get the best results?
Data examples:
I used a trial surface plot as follows:
x = [1 2]
y = [1 10]
z = [1,2;3 4]
surf(x,y,z)
view([0 90])
colorbar
Ideally, I would expect to see 4 blocks of different colors, but that is not the case. The entire surface shows up in one color. I am also unable to see the edges between the blocks. Changing the colormap by using
colormap(parula(4))
also does not make any difference.
My actual data is a 10x10 matrix with values between 0.0088 and 0.0127. The values in adjacent cells differ by really small amounts (0.00884 vs 0.00888). The data matrix is as follows:
0.00876220534845146 0.00877104243587021 0.00876090584272109 0.00876567260262740 0.00877338265553330 0.00880918902217270 0.00895731874309425 0.00951657095953469 0.0109001629521629 0.0126821110606861
0.00876247970885279 0.00876690070321591 0.00876721289176976 0.00877044328278834 0.00877564055025469 0.00881049364717492 0.00896310746064269 0.00951343028626726 0.0108689023842528 0.0126510510201670
0.00876481343830752 0.00876054127638956 0.00876546930498490 0.00876490398040193 0.00877568263726239 0.00881585329363156 0.00896272910588365 0.00952730819295550 0.0109010913028391 0.0126706393115163
0.00876600015772925 0.00876949737661547 0.00876931859294129 0.00876402911687813 0.00876557010714387 0.00881606549775236 0.00896451857976756 0.00952714448559324 0.0108471119108242 0.0125212904479189
0.00876760428031093 0.00875823445220582 0.00876319476549683 0.00876488785196009 0.00877212913497060 0.00880570616657179 0.00896058270945542 0.00948143683254961 0.0107756633536715 0.0122492486134851
0.00876724755370901 0.00875868602315279 0.00876292742174361 0.00876389151819509 0.00877614757341313 0.00880405920256963 0.00895849194783554 0.00945441140843719 0.0106578297353646 0.0117705806178655
0.00875709751801196 0.00876230443405094 0.00875877221862310 0.00875675590916622 0.00877170577177424 0.00879671567609802 0.00893077626458064 0.00937227941125520 0.0102882513321246 0.0110844990048619
0.00875236460269681 0.00875436716031473 0.00875502024420794 0.00874780733728857 0.00875710181594459 0.00877867781225910 0.00886642910075277 0.00920957851223199 0.00977919981733224 0.0102216960444418
0.00873770435277100 0.00874090882972177 0.00872472010882448 0.00873518319625914 0.00873764376473520 0.00874310305392874 0.00876976131446554 0.00885262900954216 0.00911920911788668 0.00934021837836617
0.00869739094626631 0.00869465228868750 0.00869366725125587 0.00870410776620277 0.00867693016050622 0.00864493598374698 0.00853265992213025 0.00841254480825253 0.00835353175045488 0.00832560991088847
Any ideas on how to visualize this using surf would be appreciated.
0 Comments
Accepted Answer
Chad Greene
on 10 Aug 2017
Ah, that's because surf and pcolor delete a row and column of data. I know, it's nonsensical. Try this instead:
imagesc(x,y,z)
axis xy
2 Comments
Chad Greene
on 10 Aug 2017
And if you want to change the color scale values more you can do so like
caxis([0.009 0.011])
More Answers (0)
See Also
Categories
Find more on Colormaps 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!