- 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)
3K+ Views
To make matplotlib scatterplots transparent as a group, we can change the alpha value in the scatter() method argument with a different group value.StepsSet the figure size and adjust the padding between and around the subplots.Make a method to return a grouped x and y points.Get group 1 and group 2 data points.Plot group1, x and y points using scatter() method with color=green and alpha=0.5.Plot group2, x and y points using scatter() method with color=red and alpha=0.5.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 def ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
3K+ Views
To decrease the density of x-ticks in Seaborn, we can use set_visible=False for odd positions.StepsSet the figure size and adjust the padding between and around the subplots.Create a dataframe with X-axis and Y-axis keys.Show the point estimates and confidence intervals with bars, using barplot() method.Iterate bar_plot.get_xticklabels() method. If index is even, then make them visible; else, not visible.To display the figure, use show() method.Exampleimport pandas import matplotlib.pylab as plt import seaborn as sns plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True df = pandas.DataFrame({"X-Axis": [i for i in range(10)], "Y-Axis": [i for i in range(10)]}) bar_plot = sns.barplot(x='X-Axis', y='Y-Axis', data=df) for ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
2K+ Views
A simple call to the imread method loads our image as a multi-dimensional NumPy array (one for each Red, Green, and Blue component, respectively) and imshow displays our image on the screen. Whereas, cv2 represents RGB images as multi-dimensional NumPy arrays, but in reverse order.StepsSet the figure size and adjust the padding between and around the subplots.Initialize the filename.Add a subplot to the current figure using nrows=1, ncols=2, and index=1.Read the image using cv2.Off the axes and show the figure in the next statement.Add a subplot to the current figure using nrows=1, ncols=2, and index=2.Read the image using plt.Off the ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
2K+ Views
To map values to a colors tuple(red, green and blue) in matplotlib, we can take the following steps −Create a list of values from 1.00 to 2.00, count=10.Get linearly normalized data into the vmin and vmax interval.Get an object to map the scalar data to rgba.Iterate the values to map the color values.Print the values against the mapped red, green, and blue values.Exampleimport numpy as np from matplotlib import cm, colors values = np.linspace(1.0, 2.0, 10) norm = colors.Normalize(vmin=1.0, vmax=2.0, clip=True) mapper = cm.ScalarMappable(norm=norm, cmap=cm.Greys_r) for value in values: print("%.2f" % value, "=", "red:%.2f" % mapper.to_rgba(value)[0], ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
3K+ Views
To draw a network graph with networkx and matplotlib, plt.show() −Set the figure size and adjust the padding between and around the subplots.Make an object for a dataframe with the keys, from and to.Get a graph containing an edgelist.Draw a graph (Step 3) using draw() method with some node properties.To display the figure, use show() method.Exampleimport pandas as pd import networkx as nx from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True df = pd.DataFrame({'from': ['A', 'B', 'C', 'A'], 'to': ['D', 'A', 'E', 'C']}) G = nx.from_pandas_edgelist(df, 'from', 'to') nx.draw(G, with_labels=True, node_size=100, alpha=1, linewidths=10) plt.show()OutputRead More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
166 Views
To draw R-style (default is regular style) axis ticks that point outward from the axes in matplotlib, we can use rcParams["xticks.direction"]="out" for X-axis.StepsSet the figure size and adjust the padding between and around the subplots.Set outwaord tick points using plt.rcParams.Initialize a variable for the number of data points.Create x and y data points using numpy.Plot x and y 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 plt.rcParams['ytick.direction'] = 'out' # in plt.rcParams['xtick.direction'] = 'out' # in n = 10 x = ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
2K+ Views
To convert or scale the axis values and redefine the tick frequency in matplotlib, we can make a list of xticks and xtick_labels using xticks() method. Place the axis scale and redefine the tick frequency.StepsSet the figure size and adjust the padding between and around the subplots.Initialize a variable, n, for the number of data points.Create x and y data points using numpy.Plot x and y data points using plot() method.Make lists of ticks and tick labels.Use xticks() method to place axis scale and redefine tick frequency.To display the figure, use show() method.Exampleimport numpy as np from matplotlib import pyplot ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
7K+ Views
To make a scatter plot with multiple Y values for each X, we can create x and y data points using numpy, zip and iterate them together to create the scatter plot.StepsSet the figure size and adjust the padding between and around the subplots.Create random xs and ys data points using numpy.Zip xs and ys. Iterate them together.Make a scatter plot with each x and y values.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 xs = np.random.rand(100) ys = np.random.rand(100) for x, y in zip(xs, ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
3K+ Views
Axes.flat means a 1D iterator over the array. Let's take an example to see how to use axes.flat.StepsSet the figure size and adjust the padding between and around the subplots.Create a figure and a set of subplots using subplots() method.Create x and y data points using numpy.Use axes.flat and iterate all the axes (step 2).Plot x and y 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 fig, axes = plt.subplots(nrows=2, ncols=3) x = np.random.rand(10) y = np.random.rand(10) for _, ax ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
3K+ Views
To write text above the bars on a bar plot, we can take the following stepsSet the figure size and adjust the padding between and around the subplots.Create lists of year, population and x. Initialize a width variable.Create a figure and a set of subplots using subplots() method.Set ylabels, title, xtickas and xticklabels.Plot the bars using bar() method with x, population and width data.Iterate the bar patches and place text at the top of the bars using text() method.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"] = ... Read More