How do I display different colormap for subplots? (2024)

99 views (last 30 days)

Show older comments

UTKARSH VERMA on 19 Sep 2022

  • Link

    Direct link to this question

    https://support.mathworks.com/matlabcentral/answers/1807995-how-do-i-display-different-colormap-for-subplots

  • Link

    Direct link to this question

    https://support.mathworks.com/matlabcentral/answers/1807995-how-do-i-display-different-colormap-for-subplots

Commented: UTKARSH VERMA on 20 Sep 2022

Accepted Answer: Adam Danz

HI all,

I am plotting 6 subplots in one figure in arrangement as 2 rows and 3 colums.

I want two colorbar with different colormap for every row.

How can I do it?

Thanks in advance.

0 Comments

Show -2 older commentsHide -2 older comments

Sign in to comment.

Sign in to answer this question.

Accepted Answer

Adam Danz on 19 Sep 2022

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/1807995-how-do-i-display-different-colormap-for-subplots#answer_1056485

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/1807995-how-do-i-display-different-colormap-for-subplots#answer_1056485

Open in MATLAB Online

  1. Use tiledlayout instead of subplot
  2. Assign the colormap to the axes using the axes handles
  3. Using tiledlayout, position the colorbars to the east|west|north|south

Full demo of these 3 steps

tcl = tiledlayout(2,3); % STEP 1

ax = gobjects(1,6);

for i = 1:6

ax(i) = nexttile();

peaks(15);

if i>3

colormap(ax(i),'hot') % STEP 2

else

colormap(ax(i),'cool')

end

end

z = 3*(1-x).^2.*exp(-(x.^2) - (y+1).^2) ... - 10*(x/5 - x.^3 - y.^5).*exp(-x.^2-y.^2) ... - 1/3*exp(-(x+1).^2 - y.^2) z = 3*(1-x).^2.*exp(-(x.^2) - (y+1).^2) ... - 10*(x/5 - x.^3 - y.^5).*exp(-x.^2-y.^2) ... - 1/3*exp(-(x+1).^2 - y.^2) z = 3*(1-x).^2.*exp(-(x.^2) - (y+1).^2) ... - 10*(x/5 - x.^3 - y.^5).*exp(-x.^2-y.^2) ... - 1/3*exp(-(x+1).^2 - y.^2) z = 3*(1-x).^2.*exp(-(x.^2) - (y+1).^2) ... - 10*(x/5 - x.^3 - y.^5).*exp(-x.^2-y.^2) ... - 1/3*exp(-(x+1).^2 - y.^2) z = 3*(1-x).^2.*exp(-(x.^2) - (y+1).^2) ... - 10*(x/5 - x.^3 - y.^5).*exp(-x.^2-y.^2) ... - 1/3*exp(-(x+1).^2 - y.^2) z = 3*(1-x).^2.*exp(-(x.^2) - (y+1).^2) ... - 10*(x/5 - x.^3 - y.^5).*exp(-x.^2-y.^2) ... - 1/3*exp(-(x+1).^2 - y.^2)

% STEP 3

cb1 = colorbar(ax(3));

cb1.Layout.Tile = 'east';

cb1.Label.String = 'Vanilla Ice';

cb1 = colorbar(ax(6));

cb1.Layout.Tile = 'east';

cb1.Label.String = 'MC Hammer';

How do I display different colormap for subplots? (3)

3 Comments

Show 1 older commentHide 1 older comment

UTKARSH VERMA on 19 Sep 2022

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/1807995-how-do-i-display-different-colormap-for-subplots#comment_2370740

  • Link

    Direct link to this comment

    https://support.mathworks.com/matlabcentral/answers/1807995-how-do-i-display-different-colormap-for-subplots#comment_2370740

Hi Adam,

Thanks for your reply.

Can you tell me If I want to use caxis for the each tiledplot, is it possible?

Adam Danz on 19 Sep 2022

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/1807995-how-do-i-display-different-colormap-for-subplots#comment_2370850

  • Link

    Direct link to this comment

    https://support.mathworks.com/matlabcentral/answers/1807995-how-do-i-display-different-colormap-for-subplots#comment_2370850

Indeed!

Call the clim function for each axis specifying the same limits since you're using 1 colorbar scale for those axes.

UTKARSH VERMA on 20 Sep 2022

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/1807995-how-do-i-display-different-colormap-for-subplots#comment_2372720

  • Link

    Direct link to this comment

    https://support.mathworks.com/matlabcentral/answers/1807995-how-do-i-display-different-colormap-for-subplots#comment_2372720

Thanks Adam!

Sign in to comment.

More Answers (1)

vamshi sai yele on 19 Sep 2022

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/1807995-how-do-i-display-different-colormap-for-subplots#answer_1056550

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/1807995-how-do-i-display-different-colormap-for-subplots#answer_1056550

Open in MATLAB Online

Hello,

I understood that you want to display different colors in a subplot.

I have tried it from my end and below is the solution for the same.

x=0:0.1:10;

y1 = cos(x)

y2 = sin(x)

subplot(2,2,1)

plot(x,y1,'Color','r') ;

colorbar

subplot(2,2,2)

plot(x,y2,'Color','r') ;

colorbar

subplot(2,2,3)

plot(x,y1,'Color','b') ;

colorbar

subplot(2,2,4)

plot(x,y2,'Color','b') ;

colorbar

How do I display different colormap for subplots? (8)

In this example we have used 2x2 subplot and assigned red color to first row and blue color to second row. In this way we can set colors to individual plots as well.

We may also include different styled markers with different colors on the graph line. For such more options and better understanding of this concept, kindly refer to the following resources.

Resource-1

Resource-2

Resource-3

Hope you find it helpful!

1 Comment

Show -1 older commentsHide -1 older comments

UTKARSH VERMA on 20 Sep 2022

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/1807995-how-do-i-display-different-colormap-for-subplots#comment_2372740

  • Link

    Direct link to this comment

    https://support.mathworks.com/matlabcentral/answers/1807995-how-do-i-display-different-colormap-for-subplots#comment_2372740

Thanks Vamsi, it was great help.

Sign in to comment.

Sign in to answer this question.

See Also

Categories

MATLABGraphicsFormatting and AnnotationColormaps

Find more on Colormaps in Help Center and File Exchange

Tags

  • subplot
  • colormap

Products

  • MATLAB

Release

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.


How do I display different colormap for subplots? (10)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom(English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Contact your local office

How do I display different colormap for subplots? (2024)

References

Top Articles
Advanced Eye Care Bowling Green Missouri
Uw Oshkosh Wrestling
Spasa Parish
Rentals for rent in Maastricht
159R Bus Schedule Pdf
Sallisaw Bin Store
Black Adam Showtimes Near Maya Cinemas Delano
Espn Transfer Portal Basketball
Pollen Levels Richmond
11 Best Sites Like The Chive For Funny Pictures and Memes
Finger Lakes 1 Police Beat
Craigslist Pets Huntsville Alabama
Paulette Goddard | American Actress, Modern Times, Charlie Chaplin
Red Dead Redemption 2 Legendary Fish Locations Guide (“A Fisher of Fish”)
What's the Difference Between Halal and Haram Meat & Food?
R/Skinwalker
Rugged Gentleman Barber Shop Martinsburg Wv
Jennifer Lenzini Leaving Ktiv
Justified - Streams, Episodenguide und News zur Serie
Epay. Medstarhealth.org
Olde Kegg Bar & Grill Portage Menu
Cubilabras
Half Inning In Which The Home Team Bats Crossword
Amazing Lash Bay Colony
Juego Friv Poki
Dirt Devil Ud70181 Parts Diagram
Truist Bank Open Saturday
Water Leaks in Your Car When It Rains? Common Causes & Fixes
What’s Closing at Disney World? A Complete Guide
New from Simply So Good - Cherry Apricot Slab Pie
Drys Pharmacy
Ohio State Football Wiki
Find Words Containing Specific Letters | WordFinder®
FirstLight Power to Acquire Leading Canadian Renewable Operator and Developer Hydromega Services Inc. - FirstLight
Webmail.unt.edu
2024-25 ITH Season Preview: USC Trojans
Metro By T Mobile Sign In
Restored Republic December 1 2022
12 30 Pacific Time
Jami Lafay Gofundme
Greenbrier Bunker Tour Coupon
No Compromise in Maneuverability and Effectiveness
Black Adam Showtimes Near Cinemark Texarkana 14
Teamnet O'reilly Login
U-Haul Hitch Installation / Trailer Hitches for Towing (UPDATED) | RV and Playa
Wie blocke ich einen Bot aus Boardman/USA - sellerforum.de
Infinity Pool Showtimes Near Maya Cinemas Bakersfield
Dermpathdiagnostics Com Pay Invoice
How To Use Price Chopper Points At Quiktrip
Maria Butina Bikini
Busted Newspaper Zapata Tx
Latest Posts
Article information

Author: Prof. Nancy Dach

Last Updated:

Views: 5859

Rating: 4.7 / 5 (77 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Prof. Nancy Dach

Birthday: 1993-08-23

Address: 569 Waelchi Ports, South Blainebury, LA 11589

Phone: +9958996486049

Job: Sales Manager

Hobby: Web surfing, Scuba diving, Mountaineering, Writing, Sailing, Dance, Blacksmithing

Introduction: My name is Prof. Nancy Dach, I am a lively, joyous, courageous, lovely, tender, charming, open person who loves writing and wants to share my knowledge and understanding with you.