
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 10476 Articles for Python

1K+ Views
To plot two violin plot series on the same graph using Seaborn, we can take the following Steps.StepsSet the figure size and adjust the padding between and around the subplots.Load an example dataset from the online repository (requires Internet).Create a violin plot using violinplot() method.To display the figure, use Show() method.Example# Import Seaborn and Matplotlib import seaborn as sns from matplotlib import pyplot as plt # Set the figure size plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True # Load an example dataset tips = sns.load_dataset("tips") # Create a violin plot using Seaborn sns.violinplot(x="day", y="total_bill", hue="time", data=tips) ... Read More

474 Views
To autosize text in matplotlib, we can make a tight layout and rotate the ticks.StepsSet the figure size and adjust the padding between and around the subplots.Plot data points of the range of 10.Make a list of labels.Put ticks and labels on the X-axis with 30 rotation.To display the figure, use Show() method.Examplefrom matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True plt.plot(range(10)) labels = [7 * repr(i) for i in range(10)] plt.xticks(range(10), labels, rotation=30) plt.show() OutputIt will produce the following output −

17K+ Views
To change the scale of imshow in matplotlib without stretching the image, we can take the following steps.StepsSet the figure size and adjust the padding between and around the subplots.Create random data points with 4×4 dimension.Display the data as an image, i.e., on a 2D regular raster.Use the extent parameter of imshow to map the image buffer pixel coordinates to a data space coordinate system.Next, set the aspect ratio of the image manually by supplying a value such as "aspect=4" or let it auto-scale by using aspect='auto'. This will prevent stretching of the image. By default, imshow sets the aspect of ... Read More

723 Views
In a profile histogram, each bin contains the mean of its entries. To plot profile histograms in Python, we can use the regplot method from Seaborn.StepsSet the figure size and adjust the padding between and around the subplots.Create x and y data points using numpy.Use seaborn.regplot to plot the data and a linear regress model fit. Use the parameter x_bins to bin the x variable into discrete bins. Use fit_reg=True to plot the regression model relating the x and y variables.To display the figure, use Show() method.Exampleimport numpy as np import seaborn as sns from matplotlib import pyplot as plt ... Read More

604 Views
To use ax.get_ylim() method in matplotlib, we can take the following steps.StepsSet the figure size and adjust the padding between and around the subplots.Create a new figure or activate an existing figure.Add an 'ax' to the figure as part of a subplot arrangement.Create random data points using numpy.Plot y data points using plot() method.Use ax.get_ylim() method to print it.To display the figure, use Show() method.Exampleimport numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True fig = plt.figure() # Add an axes to the figure ax = fig.add_subplot(1, 1, 1) ... Read More

485 Views
The isUndefined() method in AngularJS basically checks if a reference is defined or not. This method will return True if the reference passed inside the function is not defined or undefined, else it will return False.Syntaxangular.isUndefined(value)Example − Check if the reference isUndefined or notCreate a file "isUndefined.html.3" in your Angular project directory and copy-paste the following code snippet. angular.isUndefined() Welcome to Tutorials Point AngularJS | ... Read More

5K+ Views
The forEach() function in AngularJS uses the Iterator object to iterate over the collection of items or objects or an array. The iterator function is called with the iterator object(value, key, obj) where, value represents the object property or an array element, key specifies the object property key or array element index, andobj represents the whole object.Note that the forEach() function does not iterate over the inherited properties.Syntaxangular.forEach(obj, iterator, [context])Example − Iterate the values using forEach()Create a file "forEach.html" in your Angular project directory and copy-paste the following code snippet. angular.forEach() ... Read More

331 Views
Suppose we have a directed graph with n colored nodes and m different edges. And the nodes are numbered from 0 to n-1. We have a string col with lowercase letters, where col[i] represents the color of the ith node in this graph (0-indexed). We also have an edge list where edges[j] = (u, v) represents, there is an edge between u and v.A valid path in the graph is a sequence of nodes xi for all i from 1 to k, such that there is a directed edge from xi to xi+1. The color of the path is the ... Read More

381 Views
Suppose we have a list of intervals, where intervals[i] has a pair (left_i, right_i) represents the ith interval starting at left_i and ending at right_i (both inclusive). We also have another array called queries. The answer to the jth query is the size of the smallest interval i such that left_i

205 Views
Suppose there is an array called rooms. where rooms[i] contains a pair [roomId_i, size_i] denotes a room whose id is roomId_i and size is size_i. All room numbers are distinct. We also have another array queries, where queries[j] contains a pair [preferred_j, minSize_j]. The answer to the jth query is the room number id of a room such that −The room has size of at least minSize_j, and|id - preferred_j| is minimized.Now, if there is a tie in the absolute difference, then use the room with the smallest id. If there is no such room, return -1. So we have ... Read More