MATLAB subplot: how to have 1 colorbar for both images?

  • Context: MATLAB 
  • Thread starter Thread starter mikeph
  • Start date Start date
  • Tags Tags
    Images Matlab
Click For Summary
SUMMARY

This discussion addresses the challenge of displaying two 2D surface matrices in MATLAB using the subplot function while maintaining a single colorbar for both images. The user initially creates separate colorbars for each subplot, which complicates visual comparison. The solution involves scaling both images to the same color range and disabling one of the colorbars to enhance clarity. The provided code snippets illustrate the use of the pcolor function and colorbar management in MATLAB.

PREREQUISITES
  • Familiarity with MATLAB programming environment
  • Understanding of the pcolor function for 2D surface plotting
  • Knowledge of figure handles and subplot management in MATLAB
  • Basic concepts of color scaling in data visualization
NEXT STEPS
  • Learn about MATLAB color scaling techniques for consistent data representation
  • Explore advanced figure handle manipulation in MATLAB
  • Research the use of the colormap function to customize colorbars
  • Investigate the implications of using different plotting functions like surf and mesh in MATLAB
USEFUL FOR

This discussion is beneficial for MATLAB users, data scientists, and researchers who need to visualize and compare multiple datasets effectively using color representation.

mikeph
Messages
1,229
Reaction score
18
Title says it all. I have two matrices representing 2D surfaces, and I am using subplot to compare them in the same plat area, however, each has its own colorbar so comparison is not so easy to do by eye.

I'm pretty weak at figure handles, can someone give me a hint to do this? Thanks

Code:
subplot(1,2,1); h1 = pcolor(final); 
set(h1,'EdgeAlpha',0); colorbar
subplot(1,2,2); h2 = pcolor(initial);
set(h2,'EdgeAlpha',0); colorbar

Thanks
 
Physics news on Phys.org
scale each image the same and then turn off one of the colorbars, they are not necessary for each subplot
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
8K
Replies
7
Views
2K
  • · Replies 1 ·
Replies
1
Views
9K