EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • Featured Skills
    • New & Trending
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Log in
  • Sign Up
Home Data Science Data Science Tutorials Matlab Tutorial Matlab colorbar Label
 

Matlab colorbar Label

Priya Pedamkar
Article byPriya Pedamkar

Updated March 27, 2023

Matlab colorbar Label

 

 

Introduction to Matlab colorbar Label

Plots the ways of explaining the conclusion or inference in graphical form. Colorbar Label forms an important aspect in the graphical part of Matlab. We can add colors to our plot with respect to the data displayed in various forms. They can help us to distinguish between various forms of data and plot. After adding colorbar labels to the plot, we can change its various features like thickness, location, etc. We can assign specific colors to the most important and least important features according to the business requirements.

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

Working with Matlab colorbar Label

They are used in various plots to distinguish different features of the data set. The location of the colorbar label is always on the right side of the given axes by default but they can be adjusted by changing the “Location” property of the plot.

  • c=colorbar: This is used to give a vertical colorbar label for any plot. It specifies the data values mapping to each color in the colorbar.
  • c=colorbar (location of the bar): This syntax is used when we want to specify the location of the colorbar. It is shown on the right side of the plot by default.
  • c=colorbar (____, Name of the property, value of specified property): We can customize the appearance of the colorbar label by changing various features or properties by assigning any value to the required property. Every plot doesn’t support the customization of the colorbar.
  • c=colorbar (target axes, __): This syntax is used when we want to specify the colorbar label in the given target axes or the specified chart. This can be defined in the first argument of the syntax.
  • c=colorbar(‘off’): This command can be used when we want to delete all the colorbar labels that are present in the current axes or given plot.
  • c=colorbar (‘target axes’, ‘off’): This is used when we want to delete the colorbar labels that are present in the specified axes as given in the first argument of the syntax. We can also specify any colorbar object in the target value.

Examples of Matlab colorbar Label

Please find the below examples that show the use of colorbar label in Matlab with various plots:

Example #1 – To use colorbar label in the surface plot

Code:

s=surf(peaks)
c=colorbar

Output:

matlab colorbar label 1

In the above example, the colorbar label is shown in the right-hand side of the plot that matches the data values present in the plot with the colors shown in the colormap. The color is shown in the range of data values.

Example #2 – To plot the colorbar label in a location given as input to the chart

Code:

s=surf(peaks)
c=colorbar("northoutside")

Output:

matlab colorbar label 2

In the above example, the colorbar label is shown in the above of the plot because we have mentioned it in the code as “northoutside” and if it is mentioned as “southoutside” then the colorbar will be present in the bottom of the plot. We can also reverse the direction values that are present in the colorbar label. By default, the smaller values are present in the bottom side of the bar and larger values are present at the top. So, we can use the syntax that uses the name and value of the property and use it accordingly like the colorbar (‘Direction’, ‘reverse’). There are many other properties that can be used to customize the colorbar label in Matlab. As seen in Example 2, we can change the location of the colorbar label in the plot.

There are various location values that can be given to the property like:

  • north: This will plot the colorbar label on top of the axes of the chart. The orientation of the colorbar will be horizontal in nature.
  • northoutside: This will plot the colorbar label at the top of the chart and it will be outside of the plot. The orientation of the colorbar will be horizontal in nature.
  • south: This will plot the colorbar label at the bottom of the axes of the chart. The orientation of the colorbar will be horizontal in nature.
  • southoutside: This will plot the colorbar label at the bottom of the chart and it will be outside of the plot. The orientation of the colorbar will be horizontal in nature.
  • east: This will plot the colorbar label in the right of the axes of the chart. The orientation of the colorbar will be vertical in nature.
  • eastoutside: This will plot the colorbar label in the right of the chart and it will be outside of the plot. The orientation of the colorbar will be vertical in nature. This is the default location that is used while drawing the plot using colorbar
  • west: This will plot the colorbar label on the left of the axes of the chart. The orientation of the colorbar will be vertical in nature.
  • westoutside: This will plot the colorbar label on the left of the chart and it will be outside of the plot. The orientation of the colorbar will be vertical in nature.
  • We can also give the tick locations in the plot by giving the numerical values in the form of a vector. The datatypes that are accepted are single and double the values that are displayed in the vector are not required to be spaced equally. If we don’t want any tick marks, then we can assign an empty vector like []. We can also assign the tick mode property by setting it to auto or manual. If it is set to ‘auto’ then it will automatically select the tick values while if it is manual, then we have to manually assign the values using the ‘Ticks’.
  • We can also set the minimum and maximum tick values that are required in the plot. It can be defined in a two-element vector.

Example #3 – To delete the colorbar label from the plot

Code:

s=surf(peaks)
c=colorbar
c=colorbar('off')

Output:

Example 3

Conclusion

Colorbar Labels in Matlab can be used in all the plots like surface or contour plots. There are various properties associated with it, which are customized to change the look and feel of the colorbar label.

Recommended Articles

This has been a guide to Matlab colorbar Label. Here we discuss the introduction, working, and examples of Matlab colorbar Label. You may also have a look at the following articles to learn more –

  1. Square Root in Matlab
  2. Arrays in Matlab
  3. Matlab Create Function
  4. Matlab Logical Operators

Primary Sidebar

Footer

Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA Login

Forgot Password?

🚀 Limited Time Offer! - 🎁 ENROLL NOW