Dev Prakash Sharma has Published 556 Articles

Daily Temperatures in C++

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 23-Feb-2021 15:26:08

299 Views

Let us suppose we have an array of positive temperatures which represent the temperatures T. The task is to calculate how many days are there for the next warmer temperature in the given list.For exampleInput-1: T = [ 73, 74, 75, 71, 69, 72, 76, 73]Output: [1, 1, 4, 2, 1 ,1 ... Read More

How to Capture a pick event and use it to activate or deactivate Line Plots in Matplotlib

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 23-Feb-2021 14:52:11

394 Views

After enabling the pick event property of artists in Matplotlib, the task is to use the pick event to enable and disable the line plots for a given axis in a set of plots.In order to pick a specific line plot, we use Legend.We will use a Binary classification plot ... Read More

How to add annotations in Matplotlib Plots?

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 23-Feb-2021 14:50:37

312 Views

To specify the details of a plot, we use annotations. To create annotations in Matplotlib Plots, we can use the ‘annotate’ method.Exampleimport matplotlib.pyplot as plt import numpy as np #Let us create a plot and use annotation at the point (5, 3), x = np.arange(0, 4*np.pi, 0.1) ... Read More

How to customize spines of Matplotlib figures?

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 23-Feb-2021 14:48:37

769 Views

When we plot a figure in Matplotlib, it creates four spines around the figure, top, left, bottom and right. Spines are nothing but a box surrounded with the pictorial representation of the grid which displays some ticks and tickable axes on left(y) and bottom(x).Let us see how to customize the ... Read More

How to customize the color and colormaps of a Plot in Matplotlib

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 23-Feb-2021 14:47:58

460 Views

To customize the color and colormaps of a plot, we can use the colormap property from the color library. There are two types of colormap we can create: (a) discrete colormap and (b) continuous colormap.We will first see how to create a discrete colormap followed by continuous colormap.In the example, ... Read More

How to plot Time Zones in a map in Matplotlib

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 23-Feb-2021 14:46:09

273 Views

Let us consider that we have some data in which we have to deal with the actual time. To plot the time-zones on the map, we can use the ‘cartopy’ or ‘metPy’ package in Python. However, we can install ‘cartopy’ package in the Anaconda environment using the commands, conda install ... Read More

Yen's k-Shortest Path Algorithm in Data Structure

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 23-Feb-2021 06:35:29

1K+ Views

Instead of giving a single shortest path, Yen’s k-shortest path algorithm gives k shortest paths so that we can get the second shortest path and the third shortest path and so on.Let us consider a scenario that we have to travel from place A to place B and there are ... Read More

How to manage image resolution of a graph in Matplotlib

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 23-Feb-2021 06:25:45

1K+ Views

An Image contains a 2-D matrix RGB data points which can be defined by the dots point per inch [ DPI ] of the image. The resolution of the image is important because a hi-resolution image will have much more clarity.We have a method ‘plt.savefig()’ in Matplotlib which determines the ... Read More

How to provide shadow effect in a Plot using path_effect attribute in Matplotlib

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 23-Feb-2021 06:25:32

889 Views

In order to provide path effects like shadow effect in a plot or a graph, we can use the path_effect attribute.For example, let’s see how we can use the path_effect attribute in Matplotlib add a shadow effect to a sigmoid function.import matplotlib.pyplot as plt import numpy as np from matplotlib.patheffects ... Read More

How to plot with multiple color cycle using cycler property in Matplotlib

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 23-Feb-2021 06:21:53

603 Views

Matplotlib has a default color cycle for all the graphs and plots, however, in order to draw plots with multiple color cycles, we can use the cycler property of Matplotlib. It is used to plot repetitive patterns for the axis.First, we will use the Object Oriented APIs such as pyplot ... Read More

Advertisements