Rishikesh Kumar Rishi has Published 1156 Articles

How to add a text into a Rectangle in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 12-May-2021 12:12:46

6K+ Views

To add a text into a rectangle in matplotlib, we can add a label in annotate method at the center point of the rectangle.StepsCreate a figure or activate an existing figure using figure() method.Add a subplot arrangement in the current axis.To add a rectangle in the plot, use Rectangle() class to get ... Read More

How to get the center of a set of points using Python?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 12-May-2021 12:00:08

5K+ Views

To get the center of a set of points, we can add all the elements of the list and divide that sum with the length of the list so that result could be the center of the corresponding axes.StepsMake two lists of data points.Plot x and y data points using plot() method.Get ... Read More

How do I set color to Rectangle in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 12-May-2021 11:58:39

2K+ Views

To set color to a rectangle in matplotlib, we can take the following steps −Create a figure or activate an existing figure using figure() method.Add an '~.axes.Axes' to the figure as part of a subplot arrangement using add_subplot() method.A rectangle is defined via an anchor point with width and heights.Add a rectangle ... Read More

How to scale axes in Mplot3d?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 12-May-2021 11:57:04

4K+ Views

To scale axes in mplot3d, we can take the following steps −Create a figure or activate an existing figure using figure() method.Instantaite 3D axes instance using Axes3D() class.To scale X-axis, use set_xlim3d() method.To scale Y-axis, use set_ylim3d() method.To scale Z-axis, use set_zlim3d() method.To display the plot, use show() method.Examplefrom mpl_toolkits.mplot3d import Axes3D from ... Read More

How to increase the font size of the legend in my Seaborn plot using Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 12-May-2021 11:55:28

4K+ Views

To increase the font size of the legend in a Seaborn plot, we can use the fontsize variable and can use it in legend() method argument.StepsCreate a data frame using Pandas. The keys are number, count, and select.Plot a bar in Seaborn using barplot() method.Initialize a variable fontsize to increase the ... Read More

How to adjust the size of a Matplotlib legend box?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 12-May-2021 11:52:48

7K+ Views

To adjust the size of a matplotlib legend box, we can use borderpad arguments in the legend method.StepsCreate line1 and line2 using two lists with different line widths.To place a legend on the figure and to adjust the size of legend box, use borderpad=2 in legend() method.To display the figure, use show() method.Examplefrom matplotlib import ... Read More

How to decrease the density of tick labels in subplots in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 12-May-2021 11:51:13

1K+ Views

To decrease the density of tick labels in subplots in matplotlib, we can assign the minimum value to density.StepsInitialize a variable, density.Create x and y data points using numpy.Plot x and y data points using plot() method.Get or set the current tick locations and labels of the X-axis using xticks() method.To display the figure, ... Read More

How to switch axes in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 12-May-2021 11:49:46

8K+ Views

To switch axes in matplotlib, we can create a figure and add two subplots using subplots() method. Plot curves, extract x and y data, and set these data in a second plotted curve.StepsCreate x and y data points using numpy.Create a figure and add a set of two subplots.Set the ... Read More

Place text inside a circle in Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 12-May-2021 11:47:57

2K+ Views

To place text inside a circle in matplotlib, we can take the following steps −Create a new figure or activate an existing figure using figure() method.Add a subplot method to the current axis.Create a Circle instance using Circle() class.Add a circle path on the plot.To place the text in the circle, we can use text() method.Scale ... Read More

How to reshape a networkx graph in Python?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 12-May-2021 11:45:40

408 Views

To reshape a networkx graph in Python, we can take the following steps −Create a data frame using Panda's data frame.Return a graph from Pandas DataFrame containing an edge list using from_pandas_edgelist() method.Draw the graph G with matplotlib. We can reshape the network by increasing and decreasing the list of keys "from" ... Read More

Advertisements