Rishikesh Kumar Rishi has Published 1162 Articles

How to make the marker face color transparent without making the line transparent in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 09-Apr-2021 13:01:41

4K+ Views

To make the marker face color transparent without making the line transparent in matplotlib, we can take the following steps −Create x_data and y_data(sin(x_data)), using numpy.Plot curve using x_data and y_data, with marker style and marker size. By changing the alpha, we can make it transparent to opaque.To get the essence of ... Read More

How to extract a subset of a colormap as a new colormap in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 09-Apr-2021 13:01:23

769 Views

To extract a subset of a colormap as a new colormap, we can take the following steps −Create a random array with 10×10 shape.Add a subplot to the current figure, where nrows=1, ncols=2 and index=1.Initialize using get_cmap so that scatter knows.Using imshow() method with colormap, display the data as an image, ... Read More

Defining a discrete colormap for imshow in Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 09-Apr-2021 13:01:03

2K+ Views

To define a discrete colormap for imshow in matplotlib, we can take following the steps −Create data using numpy.Initialize the data using get_cmap, so that scatter knows.Using imshow() method with colormap, display the data as an image, i.e., on a 2D regular raster.Create the colorbar using the colorbar() method.To display the figure, ... Read More

How to enforce axis range in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 09-Apr-2021 13:00:44

600 Views

To enforce axis range in matplotlib, we can take the following steps −Set x and y limits using xlim and ylim methods, respectively.Create x and y points for the curve using numpy.Plot x and y using the plot() method.To show the figure, use the show() method.Exampleimport matplotlib.pyplot as plt import datetime import numpy as ... Read More

How to plot a time series in Python?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 09-Apr-2021 12:37:07

3K+ 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 the plot() method.To display the figure, use the show() method.Exampleimport matplotlib.pyplot as plt import datetime import numpy as np plt.rcParams["figure.figsize"] = ... Read More

Plot multiple columns of Pandas dataframe on the bar chart in Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 09-Apr-2021 12:36:13

515 Views

To plot multiple columns of a Pandas dataframe on the bar chart in matplotlib, we can take the following steps −Make a dictionary of different keys, between 1 to 10 range.Make a dataframe using Pandas dataframe.Create a bar plot, using the plot() method with kind=”bar”.To display the figure, use the show() method.Exampleimport ... Read More

How to hide ticks label in Python but keep the ticks in place?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 09-Apr-2021 12:34:58

774 Views

To hide ticks label and keep the ticks in place, we can take the following steps −Initialize x1 and x10 variables to get the x and y points, using numpy.Plot points x and y using the plot() method.Using xticks method, get or set the current tick locations and labels of ... Read More

Get the list of figures in Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 09-Apr-2021 12:33:51

985 Views

To get the list of figures in matplotlib, we can take the following steps −Using figure() method, create a new figure, or activate an existing figure. Creating x figures, i.e., x=3.To get the list of figures, use the plt.get_fignums() method.Examplefrom matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] ... Read More

How to get the color of the most recent plotted line in Python?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 09-Apr-2021 12:33:07

3K+ Views

To get the color of the most recent plotted line, we can take the following steps −Create x and y points using numpy.Plot the line using x and y, with color red and linewidth 2.To get the color of the line, use the get_color() method, and print it.To display the ... Read More

Matplotlib log scale tick label number formatting

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 09-Apr-2021 12:32:04

458 Views

To set the log scale tick label number on the axes, we can take the following steps −Set x and y axis limits (1 to 100), using ylim and xlim, on both the axes.Using loglog() method, make a plot with log scaling on both the x and y axis.To display the figure, use ... Read More

Advertisements