
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

2K+ Views
To combine several matplotlib axes subplots into one figure, we can use subplots() method with nrow=2.StepsSet the figure size and adjust the padding between and around the subplots.Create x, y1 and y2 data points using numpy.Create a figure and a set of subplots.Plot x, y1 and y2 data points using plot() method.To display the figure, use show() method.Exampleimport numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(-10, 10, 100) y1 = np.sin(x) y2 = np.cos(x) fig, axes = plt.subplots(nrows=2) line1, = axes[0].plot(x, y1, color='red') line2, ... Read More

1K+ Views
To get xkcd font working, we can use plt.xkcd() to turn on sketch-style drawing mode.StepsSet the figure size and adjust the padding between and around the subplots.Create x and y data points using numpy.Use plt.xkcd() to turn on sketch-style drawing mode.Create a new figure or activate an existing figure.Add an axis to the figure as part of a subplot arrangement.Plot x and y data points using plot() method.Place a text and title on the plot.To display the figure, use show() method.Examplefrom matplotlib import pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x ... Read More

2K+ Views
To make colorbar orientation horizontal in Python, we can use orientation="horizontal" in the argument.StepsSet the figure size and adjust the padding between and around the subplots.Create random x, y and z data points using numpy.Create a figure and a set of subplots.Use scatter() method to plot x, y and z data points.Create a colorbar for a ScalarMappable instance, with horizontal orientation.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 x, y, z = np.random.rand(3, 50) f, ax = plt.subplots() points = ax.scatter(x, y, c=z, s=50, ... Read More

17K+ Views
To show points coordinate in a plot in Python, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create lists of x and y data points.Plot x and y data points with red color and starred markerSet some axis properties.Iterate x and y to show the coordinates on the plot.Exampleimport matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = [3, 1, 2, 5] y = [5, 2, 4, 7] plt.plot(x, y, 'r*') plt.axis([0, 6, 0, 20]) for i, j in zip(x, y): plt.text(i, ... Read More

59K+ Views
To plot an array in Python, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create two arrays, x and y, using numpy.Set the title of the curve using title() method.Plot x and y data points, with red color.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 x = np.array([5, 4, 1, 4, 5]) y = np.sort(x) plt.title("Line graph") plt.plot(x, y, color="red") plt.show()Output

2K+ Views
To create curved edges with NetworkX in Python3, we can use connectionstyle="arc3, rad=0.4".StepsSet the figure size and adjust the padding between and around the subplots.Initialize a graph with edges, name, and graph attributes.Add nodes to the created graph.Add edges from one node to another.Draw the graph G with Matplotlib, with connectionstyle="arc3, rad=0.4".To display the figure, use show() method.Exampleimport matplotlib.pylab as plt import networkx as nx plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True G = nx.DiGraph() pos = nx.spring_layout(G) G.add_nodes_from([1, 2, 3, 4]) G.add_edges_from([(1, 2), (2, 4), (2, 3), (4, 1)]) nx.draw(G, with_labels=True, connectionstyle="arc3, rad=0.4") plt.show()OutputRead More

1K+ Views
To create a diverging stacked bar chart in Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Initialize a variable N to get the number of indices.Get menMeans, womenMeans, menStd and womenStd tuple.Initialize the width of bars.Create a figure and a set of subplots.To get diverging bar, we can put the data with positive and negative values to make diverging bars.Add a horizontal line across the axis.Set Ylabel, title, ticks, ticklabels, and legend.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.50, ... Read More

4K+ Views
To use Matplotlib to plot PySpark SQL results, we can take the following steps−Set the figure size and adjust the padding between and around the subplots.Get the instance that is the main Entry Point for Spark functionality.Get the instance of a variant of Spark SQL that integrates with the data stored in Hive.Make a list of records as a tuple.Distribute a local Python collection to form an RDD.Map the list record as a DB schema.Get the schema instance to make an entry into "my_table".Insert a record into a table.Read the SQL query, retrieve the record.Convert the fetched record into a ... Read More

549 Views
To manipulate figures while a script is running in Python, 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.Get the current axis, ax, and show the current figure.Manipulate the script using plt.pause() method, before the final plot.Plot the line using plot() method.To display the figure, use show() method.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

844 Views
To plot a kernel density plot of dates in Pandas using Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create a Pandas dataframe.Format the Pandas date column.Plot the Pandas date as kernel density estimate class by name.Set xtick labels using set_xticklabels() method.To display the figure, use show() method.Exampleimport pandas as pd import numpy as np import datetime import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True dates = pd.date_range('2010-01-01', periods=31, freq='D') df = pd.DataFrame(np.random.choice(dates, 100), columns=['dates']) df['ordinal'] = [x.toordinal() for x in df.dates] ... Read More