- 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
542 Views
To decrease the hatch density in Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Make a customized horizontal hatch class to override the density.Append the horizontal hatch class.Create a new figure or activate an existing figure.Add an 'ax1' to the figure as part of a subplot arrangement.Make lists of data points.Make a bar plot with x and ydata points, with hatch='o', color='green' and edgecolor='red'.To display the figure, use show() method.Examplefrom matplotlib import pyplot as plt, hatch plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True class MyHorizontalHatch(hatch.HorizontalHatch): def ... Read More
2K+ Views
To make a quiver plot in polar coordinates using Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create radii, thetas, theta and r data points using numpy.Create a new figure or activate an existing figure.Add an 'ax' to the figure as part of a subplot arrangement.Make poly collections of arrows.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 radii = np.linspace(0, 1, 5) thetas = np.linspace(0, 2 * np.pi, 20) theta, r = ... Read More
13K+ Views
To have a function return a figure in Python (using 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.Make a function plot(x, y) that creates a new figure or activate an existing figure using figure() method.Plot the x and y data points using plot() method; return fig instance.Call plot(x, y) method and store the figure instance in a variable, f.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"] = ... Read More
268 Views
We can use ax.loglog(x, y) and set_major_formatter() methods to replace tick labels with computed values.StepsSet the figure size and adjust the padding between and around the subplots.Create a figure and a set of subplots.Make a plot with log scaling on both the X and Y axis.Set the formatter of the major ticker.To display the figure, use show() method.Exampleimport numpy as np from matplotlib import pyplot as plt, ticker plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig, ax = plt.subplots() ax.loglog(np.logspace(0, 5), np.logspace(0, 5)**2) ax.xaxis.set_major_formatter(ticker.LogFormatterExponent()) plt.show()OutputRead More
375 Views
To make a simple lollipop plot in Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Make a dataframe, df, of two-dimensional, size-mutable, potentially heterogeneous tabular data.Make an ordered dataframe, using sort_values().Make a list in the range of dataframe index.Create a stem plot, using the ordered dataframe.Set xticks and labels using xticks() method.To display the figure, use show() method.Exampleimport numpy as np from 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({'group': list(map(chr, range(65, 85))), 'values': np.random.uniform(size=20)}) ... Read More
6K+ Views
To put the line title at the bottom of a figure 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 sample data.Plot the x and y data points using scatter() method.Set the title at the bottom of the figure in matplotlib, with y=-0.01.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 N = 100 x = np.random.rand(N) y = np.random.rand(N) plt.scatter(x, y, c=x, ... Read More
1K+ Views
To make multipartite graph in networkx, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create a list of subset sizes and colors.Define a method for multilayered graph that could return a multilayered graph object.Set the color of the nodes.Position the nodes in layers of straight lines.Draw the graph G with Matplotlib.Set equal axis properties.To display the figure, use show() method.Exampleimport itertools import matplotlib.pyplot as plt import networkx as nx plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True subset_sizes = [5, 5, 4, 3, 2, 4, 4, 3] subset_color = ... Read More
2K+ Views
To plot the difference of two distributions 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 datasets using Numpy.Get kdea and kdeb, i.e., representation of a kernel-density estimate using Gaussian kernels.Create a grid using Numpy.Plot the gird with kdea(grid), kdeb(grid) and kdea(grid)-kdeb(grid), using plot() method.Place the legend at the upper-left corner.To display the figure, use show() method.Exampleimport numpy as np import matplotlib.pyplot as plt import scipy.stats plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True a = np.random.gumbel(50, 28, 100) b = np.random.gumbel(60, 37, 100) ... Read More
230 Views
The Axes class contains most of the figure elements − Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system.stepsSet the figure size and adjust the padding between and around the subplots.Set the axes linewidth using rcParams.Add an axes to the current figure and make it the current axes.Set the axes spines color.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 plt.rcParams['axes.linewidth'] = 5 ax = plt.axes() ax.spines['bottom'].set_color('yellow') ax.spines['top'].set_color('red') ax.spines['right'].set_color('black') ax.spines['left'].set_color('blue') plt.show()OutputRead More
7K+ Views
To visualize 95% confidence interval 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 sets.Get the confidence interval dataset.Plot the x and y data points using plot() method.Fill the area within the confidence interval range.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 = np.arange(0, 10, 0.05) y = np.sin(x) # Define the confidence interval ci = 0.1 * np.std(y) / np.mean(y) plt.plot(x, y, color='black', ... Read More