One of the greatest benefits of visualization is that it gives us visual access to massive amounts of data in easily digestible visuals. Matplotlib consists of multiple plots such as line, bar, scatter, histogram, etc.
Ticks — these are the values used to display specific points on the coordinate axis. It can be a number or a string. Whenever we plot the graph, the axes are adjusted and take the checkboxes by default. Matplotlib`s default ticks are usually sufficient in normal situations, but by no means optimal for every plot. Here we will see how to customize these checkboxes according to our needs.
|axis||x, y, both||Tells which axis to operate|
|reset||True, False||If True, set all parameters to default|
|direction||in, out, inout||Puts the ticks inside or outside or both|
|length||Float||Sets tick`s length|
|width||Float||Sets tick`s width|
|rotation||Float||Rotates ticks wrt the axis|
|colors||Color||Changes tick color|
|pad||Float||Distance in points between tick and label|
Example # 1: default graph
Example No. 2: Play with ticks
Suppose we don`t want to display tick values or want our ticks to be tilted or want some other setting. We can do it this way.
The main difference from the first example:
plt.xticks (np.arange (0, 51, 5))
plt.yticks (np .arange (0, 11, 1))
Changing the values in np.arange will change the tick range.
Help: Matplotlib pincers .
Mark Lutz is the global leader in Python training, author of the oldest and best-selling Python texts, and a pioneer in the Python community since 1992.
Mark Lutz is the author of the found...
Pandas for Everyone: Python Data Analysis (Addison-Wesley Data & Analytics Series), 1st Edition. Pandas for Everyone brings together the practical knowledge and insights you need to solve real-worl...
This book is not just about learning the code; even if you learn to program. If you want to program professionally, learning to code is not enough; For this reason, in addition to helping you program,...
Pandas 1.x Cookbook: Practical recipes for scientific computing, time series analysis, and exploratory data analysis using Python, 2nd Edition....