Rishikesh Kumar Rishi has Published 1156 Articles

How to write annotation outside the drawing in data coords in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 01-Jun-2021 11:43:44

1K+ Views

We can use annotate() method to place annotation outside the drawing.StepsSet the figure size and adjust the padding between and around the subplots.Create x and y data points using numpy.Create a figure and a set of subplots using subplots() method.Use scatter() method to plot x and y data points using ... Read More

Histogram for discrete values with Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 01-Jun-2021 11:43:20

3K+ Views

To plot a histogram for discrete values with matplotlib, we can use hist() method.StepsSet the figure size and adjust the padding between and around the subplots.Make a list of discrete values.Use hist() method to plot data with bins=length of data and edgecolor=black.To display the figure, use show() method.Examplefrom matplotlib import ... Read More

Plotting only the upper/lower triangle of a heatmap in Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 01-Jun-2021 11:43:04

1K+ Views

To plot only the upper/lower triangle of a heatmap in matplotlib, we can use numpy to get the masked 2D array and convert them into an image to produce a heatmap.StepsSet the figure size and adjust the padding between and around the subplots.Create a random data of 5×5 dimension.Use numpy.tri() ... Read More

Is it possible to control Matplotlib marker orientation?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 01-Jun-2021 11:42:45

590 Views

To control matplotlib marker orientation, we can use marker tuple that contains a number of sides, style and rotation or orientation of the marker.StepsSet the figure size and adjust the padding between and around the subplots.Create x and y data points using numpy.Make an array of 10 different rotations.Zip x, ... Read More

How to plot an emoji as a label for a bar in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 01-Jun-2021 11:41:01

2K+ Views

We can use annotate() to place an emoji at the top of a bar.StepsSet the figure size and adjust the padding between and around the subplots.Make a list of frequencies and labels conatining emojis.Create a new figure or activate an existing figure using figure() method.Plot bars using bar() method.Use annotate() ... Read More

Can I give a border to a line in Matplotlib plot function?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 01-Jun-2021 11:40:45

2K+ Views

To give a border to a line in matplotlib plot function, we can call plot() function twice with varying line width.StepsSet the figure size and adjust the padding between and around the subplots.Create x and y data points using numpy.Plot x and y data points where line width=10 and color=black.Again ... Read More

How to change the linewidth of a hatch in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 01-Jun-2021 11:40:06

3K+ Views

To change the linewidth of a hatch in matplotlib, we can set the linewidth of the hatch in the params.StepsSet the figure size and adjust the padding between and around the subplots.Create x and y=sin(x) data points using numpy.Set the linewidth of the hatch in the plot.Plot x and y ... Read More

Plot scatter points on 3d plot without axes and grids in Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 01-Jun-2021 11:36:01

836 Views

To plot scatter points on a 3D plot without axes in matplotlib, we can use scatter() method and make the axes OFF.StepsSet the figure size and adjust the padding between and around the subplots.Create a new figure or activate an existing figure using figure() method.Add an axis as a subplot ... Read More

Add a custom border to certain cells in a Matplotlib / Seaborn plot

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 01-Jun-2021 11:35:48

976 Views

To add a custom border to certain cells in a Matplotlib/Seaborn plot.StepsSet the figure size and adjust the padding between and around the subplots.Create a dataframe with some columns.Plot a matrix dataset as a hierarchically-clustered heatmap.Get heatmap axis as a subplot arrangement.To add a custom border to certain cells in ... Read More

How do you just show the text label in a plot legend in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 01-Jun-2021 11:34:52

1K+ Views

To just show the text label in plot legend we can use legend method with handlelength=0, handletextpad=0 and fancybox=0 in the arguments.StepsSet the figure size and adjust the padding between and around the subplots.Create random x and y data points using numpy.Create a figure and a set of subplots using ... Read More

Advertisements