Rishikesh Kumar Rishi has Published 1162 Articles

Logscale plots with zero values in Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

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

1K+ Views

To logscale plots with zero values in matplotlib, we can use xscale() and yscale() methods with "symlog" class by name.StepsSet the figure size and adjust the padding between and around the subplots.Plot two lists containing zero values using plot() method.Use yscale() method with "symlog" class by name.Use xscale() method with ... Read More

How to create a legend for a 3D bar in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

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

1K+ Views

To create a legend for a 3D bar in matplotlib, we can plot 3D bars and place a legend using legend() method.StepsSet the figure size and adjust the padding between and around the subplots.Create a new figure or activate an esxisting figure using figure() method.Add an axes to the figure ... Read More

How to plot a dashed line on a Seaborn lineplot in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

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

5K+ Views

To plot a dashed line on a Seaborn lineplot, we can use linestyle="dashed" in the argument of lineplot().StepsSet the figure size and adjust the padding between and around the subplots.Create x and y data points using numpy.Use lineplot() method with x and y data points in the argument and linestyle="dashed".To ... Read More

How to skip empty dates (weekends) in a financial Matplotlib Python graph?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

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

1K+ Views

To skip weekends in a financial graph in matplotlib, we can iterate the time in dataframe and skip the plot if weekday is 5 or 6.StepsSet the figure size and adjust the padding between and around the subplots.Create a dataframe with keys time.Iterate zipped index and time of a date ... Read More

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

2K+ 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

416 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

1K+ 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

1K+ 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

Advertisements