- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Rishikesh Kumar Rishi has Published 1162 Articles
Rishikesh Kumar Rishi
349 Views
To rotate xticklabels in matplotlib to make equal spacing between two xticklabels, we can take the following steps −Make a list of numbers from 1 to 4.Using subplot(), sdd a subplot to the current figure.Add xticks and yticks on the current subplot (using step 1).Set xtick labels by passing a list and to make ... Read More
Rishikesh Kumar Rishi
1K+ Views
To plot a colorplot of a 2D array, we can take the following steps −Create data (i.e., 2D array) using numpy.For colorplot, use imshow() method, with input data (Step 1) and colormap is "PuBuGn".To display the figure, use show() method.Exampleimport numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = ... Read More
Rishikesh Kumar Rishi
4K+ Views
To add caption below X-axis for a scatter plot, we can use text() method for the current figure.StepsCreate x and y data points using numpy.Create a new figure or activate an existing figure using figure() method.Plot the scatter points with x and y data points.To add caption to the figure, ... Read More
Rishikesh Kumar Rishi
509 Views
To plot a confusion matrix with string axis rather than integer in Python, we can take the following steps−Make a list for labels.Create a confusion matrix. Use confusion_matrix() to calculate accuracy of classification.3. Add an '~.axes.Axes' to the figure as part of a subplot arrangement.Plot the values of a 2D ... Read More
Rishikesh Kumar Rishi
1K+ Views
To hide the axes in matplotlib 3D, we can take the following steps−Create a 2D array, where x, y, z, u, v and w are the coordinates of the arrow locations and direction components of the arrow vectors.Using figure() method, create a new figure or activate an existing figure.Add an ... Read More
Rishikesh Kumar Rishi
323 Views
To set the variable point size in matplotlib, we can take the following steps−Initialize the coordinates of the point.Make a variable to store the point size.Plot the point using scatter method, with marker=o, color=red, s=point_size.To display the figure, use show() method.Examplefrom matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] ... Read More
Rishikesh Kumar Rishi
533 Views
To draw a rectangle over a specific region in a matplotlib graph, we can take the following steps −Using subplots() method, create a figure and a set of subplots, where nrows=1.Using rectangle, we can create a rectangle, defined via an anchor point and its width and height. Where, edgecolor=orange, linewidth=7, and facecolor=green.To ... Read More
Rishikesh Kumar Rishi
1K+ Views
To create a draggable legend in matplotlib, we can take the following steps −Create two lines, line1 and line2, using plot() method.Place the legend for plot line1 and line2 with ordered lables at location 1, using legend() method.To create a draggable legend, use set_draggable() method, where state=True. If state=False, then we can't drag ... Read More
Rishikesh Kumar Rishi
2K+ Views
To rescale ylim and xlim automatically, we can take the following steps −To plot a line, use plot() method and data range from 0 to 10.To scale the xlim and ylim automatically, we can make the variable scale_factore=6.Use scale_factor (from Step 2) to rescale the xlim and ylim, using xlim() and ylim() methods, respectively.To display the figure, use ... Read More
Rishikesh Kumar Rishi
6K+ Views
To plot shapely polygons and objects using matplotlib, the steps are as follows −Create a polygon object using (x, y) data points.Get x and y, the exterior data, and the array using polygon.exterior.xy.Plot x and y data points using plot() method with red color.Examplefrom shapely.geometry import Polygon import matplotlib.pyplot as plt ... Read More