- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 784 Articles for Data Visualization
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
2K+ Views
To make simple double head arrows on the axes in Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Use annotate() method to annotate the point xy with text='Arrows'. Start the tuple and end it for positions. In arrowprops dictionary, use arrowstyle "" and color='red'.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 plt.annotate('Arrows', xy=(0.1, .1), xytext=(0.5, 0.5), arrowprops=dict(arrowstyle='', color='red')) plt.show()Output
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
4K+ Views
To add legends and title to grouped histograms generated by Pandas, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create a Pandas dataframe with "a", "b", "c" and "d" keys.Plot data frame with kind="hist"Set a title for the axes.To display the figure, use show() method.Examplefrom matplotlib import pyplot as plt import pandas as pd plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True df = pd.DataFrame({'a': [1, 1, 1, 1, 3], 'b': [1, 1, 2, 1, 3], 'c': [2, 2, 2, 1, 3], 'd': [2, 1, 2, 1, 3], }) df.plot(kind='hist') plt.title("Grouped Histograms") plt.show()Output
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
1K+ Views
To plot scatter points on polar axis 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, for number of sample data.Get r, theta, area and color data using numpyCreate a new figure or activate an existing figure.Plot theta, r, colors and area, using scatter() method.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 N = 150 r = 2 * np.random.rand(N) theta = 2 * np.pi * np.random.rand(N) area = 200 ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
2K+ Views
To omit matplotlib printed output in Python/Jupeter notebook, we can take the following steps −import numpy as np.from matplotlib import pyplot as pltCreate points for x, i.e., np.linspace(1, 10, 1000)Now, plot the line using plot() method.To hide the instance, use plt.plot(x); (with semi-colon)Or, use _ = plt.plot(x).ExampleIn [1]: import numpy as np In [2]: from matplotlib import pyplot as plt In [3]: x = np.linspace(1, 10, 1000) In [4]: plt.plot(x) Out[4]: [] In [5]: plt.plot(x); In [6]: _ = plt.plot(x) In [7]:OutputOut[4]: []
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
976 Views
To save figures to pdf as raster images 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.Add an axes to the figure as part of a subplot arrangement.Create random data using numpy.Display the data as an image, i.e., on a 2D regular raster.Save the plot as pdf format.Exampleimport numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig = plt.figure() ax = fig.add_subplot(111, rasterized=True) data = np.random.rand(5, 5) ax.imshow(data, cmap="copper", aspect=True, interpolation="nearest") ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
2K+ Views
To get the color of the last figure, we can use get_color() method for every plot.Set the figure size and adjust the padding between and around the subplots.Create x and y data point using numpy.Plot (x, x), (x, x2) and (x, x3) using plot() method.Place a legend for every plot line.Get the color of each plot using get_color() method.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.arange(10) y = np.arange(10) p = plt.plot(x, y, x, y ** 2, x, y ** 3) ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
2K+ Views
To plot contourf and log scale 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, for number of sample data.Create x, y, X, Y, Z1, Z2 and z data points using numpy.Create a figure and a set of subplots.Plot contours using contourf() method.Create a colorbar for a scalar mappable instance.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt import numpy as np from numpy import ma from matplotlib import ticker, cm plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True N = 100 x ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
2K+ Views
To set the networkx edge labels offset, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Initialize a graph with edges, name, or graph attributes.Add multiple nodes.Position the nodes using Fruchterman-Reingold force-directed algorithm.Draw the graph G with Matplotlib.Draw edge labels.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() G.add_nodes_from([1, 2, 3, 4]) G.add_edges_from([(1, 2), (2, 3), (3, 4), (4, 1), (1, 3)]) pos = nx.spring_layout(G) for u, v, d in G.edges(data=True): d['weight'] ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
844 Views
To set horizontal and vertical, major and minor grid lines of a plot, we can use grid() method.StepsSet the figure size and adjust the padding between and around the subplots.Create a figure and a set of subplots.Make horizontal grid lines for major ticks.Locate minor locator on the axes.Use grid() method to make minor grid lines.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt from matplotlib.ticker import MultipleLocator plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig, ax = plt.subplots() ax.yaxis.grid(which="major", color='r', linestyle='-', linewidth=2) ml = MultipleLocator(0.10) ax.xaxis.set_minor_locator(ml) ax.xaxis.grid(which="minor", color='k', linestyle='-.', linewidth=0.7) plt.show()OutputRead More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
623 Views
To plot contour with hatching, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create x, y and z data points using numpy.Flat the x and y data points.Create a figure and a set of subplots.Plot a contour with different hatches.Create a colorbar for a scalar mappable instance.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(-3, 5, 150).reshape(1, -1) y = np.linspace(-3, 5, 120).reshape(-1, 1) z = np.cos(x) + np.sin(y) x, y = ... Read More