Rishikesh Kumar Rishi has Published 1156 Articles

Plotting points on the surface of a sphere in Python's Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 15-May-2021 12:08:19

13K+ Views

To plot points on the surface of a sphere in Python, we can use plot_surface() method.StepsCreate a new figure or activate an existing figure using figure() method.Add a set of subplots using add_subplot() method with 3d projection.Initialize a variable, r.Get the theta value for spherical points and x, y, and ... Read More

Creating a 3D plot in Matplotlib from a 3D numpy array

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 15-May-2021 12:02:05

19K+ Views

To create a 3D plot from a 3D numpy array, we can create a 3D array using numpy and extract the x, y, and z points.Create a new 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() ... Read More

How to use matplotlib.animate to animate a contour plot in Python?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 15-May-2021 12:01:38

782 Views

To animate a contour plot in matplotlib in Python, we can take the following steps−Create a random data of shape 10☓10 dimension.Create a figure and a set of subplots using subplots() method.Makes an animation by repeatedly calling a function *func* using FuncAnimation() class.To update the contour value in a function, ... Read More

How to position and align a Matplotlib figure legend?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 15-May-2021 12:01:08

2K+ Views

To position and align a matplotlib figure legend, we can take the following steps−Plot line1 and line2 using plot() method.Place a legend on the figure. Use bbox_to_anchor to set the position and make horizontal alignment of the legend elements.To display the figure, use show() method.Examplefrom matplotlib import pyplot as plt ... Read More

How can I convert numbers to a color scale in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 15-May-2021 12:00:44

3K+ Views

To convert numbers to a color scale in matplotlib, we can take the following steps.StepsCreate x, y and c data points using numpy.Convert the data points to Pandas dataframe.Create a new figure or activate an existing figure using subplots() method.Get the hot colormap.To linearly normalize the data, we can use ... Read More

Exporting an svg file from a Matplotlib figure

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 12-May-2021 12:22:14

13K+ Views

To export an SVG file from a matplotlib figure, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create a figure and a set of subplots.Create random x and y data points using numpy.Plot x and y data points using plot() method.Save ... Read More

Plot numpy datetime64 with Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 12-May-2021 12:20:25

738 Views

To plot a time series in Python using matplotlib, we can take the following steps −Create x and y points using numpy.Plot the created x and y points using plot() method.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt import datetime import numpy as np plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] ... Read More

How to give sns.clustermap a precomputed distance matrix in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 12-May-2021 12:19:02

297 Views

To give sns.clustermap a dataset, we can take the following steps −Set multiple theme parameters in one step.Load an example dataset from the online repository (requires Internet).Return item and drop from the frame. Raise KeyError if not found, using pop() method.Plot a matrix dataset as a hierarchically-clustered heatmap using clustermap() method.To display the figure, use show() ... Read More

How to plot 3D graphs using Python Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

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

2K+ Views

To plot 3D graphs using Python, we can take the following steps −Create a new figure or activate an existing figure using figure() method.Get the 3D axes object.Make x, y, and z lists for data points.Add 3D scatter points using scatter3D() method, with x, y, and z data points with markersize=150 and ... Read More

How to sharex when using subplot2grid?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 12-May-2021 12:15:15

435 Views

To sharex when using subplot2grid, we can take the following steps −Create random data, t, x, y1 and y2 using numpy.Create a new figure or activate an existing figure using figure() method.Create a subplot at a specific location inside a regular grid with colspan=3 and rowspan=2.Create a subplot at a specific location ... Read More

Advertisements