
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 26504 Articles for Server Side Programming

450 Views
To get the length of a single unit on an axis in Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create x and y data points using numpy.Create a new figure or activate an existing figure using figure() method.Add an '~.axes.Axes' to the figure as part of a subplot arrangement.Plot x and y data points using plot() method.To get the single unit length, use transData transform.Print the horizontal and vertical lengths.To display the figure, use show() method.Exampleimport numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] ... Read More

1K+ Views
To redraw an image using python's Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create a new figure or activate an existing figure.Get the current axis using gca() method.Show the current figure.Iterate in the range of 20 and redraw the plot.Use plot() method to plot random data points.Redraw on the figure and pause for a while.Close a figure window.Exampleimport numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig = plt.figure() ax = fig.gca() fig.show() for i in range(20): ... Read More

750 Views
To color the intersection of circles/patches in Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create a and b points.Get the left, right and middle area from the two points, a and b.Get the current axes using gca() methodAdd patches with different colors and sections.Set the X and Y axes scale.Set the aspect ratios equal.Turn off the axes.To display the figure, use show() method.Exampleimport shapely.geometry as sg import matplotlib.pyplot as plt import descartes plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True a = sg.Point(-.5, 0).buffer(1.) b = sg.Point(0.5, ... Read More

4K+ Views
To change the DPI of a Pandas DataFrame plot, we can use rcParams to set the dot per inch.StepsSet the figure size and adjust the padding between and around the subplots.Set the DPI values in .rcParams["figure.dpi"] = 120Create a Pandas dataframe to make a plot.Plot the dataframe.To display the figure, use show() method.Exampleimport pandas as pd from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True plt.rcParams["figure.dpi"] = 120 data = pd.DataFrame({"column1": [4, 6, 7, 1, 8]}) data.plot() plt.show()Output

478 Views
To make frames around the tiles in a Seaborn heatmap, we can use linewidths and linecolor values in the heatmap() method.StepsSet the figure size and adjust the padding between and around the subplots.Create a Pandas data frame with 5 columns.Use heatmap() method to plot rectangular data as a color-encoded matrix.To display the figure, use show() method.Exampleimport seaborn as sns import pandas as pd import numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True df = pd.DataFrame(np.random.random((5, 5)), columns=["col1", "col2", "col3", "col4", "col5"]) sns.heatmap(df, linewidths=4, linecolor='green') plt.show()OutputRead More

1K+ Views
To create a heatmap in Python that ranges from green to red, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Make a dictionary for different colors.Create a colormap from linear mapping segments using LinearSegmentedColormap.Create a figure and a set of subplots.Create random data with 5☓5 dimension.Create a pseudocolor plot with a non-regular rectangular grid.Create a colorbar for a ScalarMappable instance, *mappable*.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt import matplotlib.colors as colors import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True cdict = {'red': ... Read More

435 Views
To get all the bars in a Matplotlib chart, we can use the bar() method and return the bars.−StepsSet the figure size and adjust the padding between and around the subplots.Create a figure and a set of subplots.Create x and y data points using subplots() method.Make a bar plot and store it in bars variable.Set the facecolor of a particular set of bars.To display the figure, use show() method.Exampleimport numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig, ax = plt.subplots() x = np.arange(7) y = np.random.rand(7) bars = ax.bar(x, ... Read More

2K+ Views
To remove a frame without removing the axes tick labels from a Matplotlib figure, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create a list of y data points.Plot the y data points using plot() methodTo remove the left-right-top and bottom spines, we can use set_visible() method.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True y = [0, 2, 1, 5, 1, 2, 0] plt.plot(y, color='red', lw=7) for pos in ['right', 'top', 'bottom', 'left']: plt.gca().spines[pos].set_visible(False) plt.show()OutputRead More

2K+ Views
To get a reverse-order cumulative histogram in Matplotlib, we can use cumulative = -1 in the hist() method.Set the figure size and adjust the padding between and around the subplots.Make a list of data points.Plot a histogram with data and cumulative = -1.To display the figure, use show() method.Examplefrom matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True data = [1, 2, 2, 3, 1, 4, 3, 0, 1, 3, 0] plt.hist(data, edgecolor='black', align="mid", cumulative=-1) plt.show()Output

2K+ Views
To use an update function to animate a NetworkX graph in Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create a new figure or activate an existing figure using figure() method.Initialize a graph with edges, name, and graph attributes.Add nodes to the graph using add_nodes_from() method.Draw the graph G with Matplotlib.Use FuncAnimation() class to make an animation by repeatedly calling a function, animate.Function animate clears the current figure, generate two random numbers, and draws the edges between them.To display the figure, use show() method.Examplefrom matplotlib import pyplot as plt, ... Read More