
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 784 Articles for Data Visualization

5K+ Views
To set the margins of a matplotlib figure, we can use margins() method.StepsSet the figure size and adjust the padding between and around the subplots.Create t and y data points using numpy.Add a subplot to the current figure at index 1.Plot t and y data points using plot() method.Set the title of the plot.Add a subplot to the current figure at index 2.Plot t and y data points using plot() method.Set the title of the plot.Set margins of the plot using margins(x=0, y=0).To display the figure, use show() method.Exampleimport numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] ... Read More

9K+ Views
To set Y-axis limit, we can use ylim() method and put maximum and minimum limit values.StepsSet the figure size and adjust the padding between and around the subplots.Create two lists for data points.Make two variables for max and min values for Y-axis.Use ylim() method to limit the Y-axis range.Use bar() method to plot the bars.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 x = [1, 2, 3, 4, 5] y = [8, 4, 6, 1, 3] max_y_lim = max(y) + .5 min_y_lim = min(y) plt.ylim(min_y_lim, max_y_lim) plt.bar(x, y) ... Read More

7K+ Views
To improve matplotlib image quality we can use greater dot per inch i.e dpi value (greater than 600) and pdf or .eps format can be recommended.StepsSet the figure size and adjust the padding between and around the subplots.Make a 2D data raster using a np.array.Display data as an image, i.e., on a 2D regular raster.Save the current image using savefig() with dpi=1200 and .eps format, 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 data = np.array( [[0.1, 0.7, 0.6, 0.3], ... Read More

1K+ Views
To close a Python figure by a keyboard input, we can use plt.pause() method, an input, and close() method.StepsSet the figure size and adjust the padding between and around the subplots.Create random t and y data points using numpy.Create a new figure or activate an existing figure using figure() method.Plot t and y data points using plot() method.Set the title of the plot.Redraw the current figure using draw() method.Run a true loop to pause the current figure.Take input from the user to go to the next statement.Use close() method to close the figure.Exampleimport numpy as np from matplotlib import pyplot ... Read More

1K+ Views
To display an np.array with imshow(), we can take the following stepsSet the figure size and adjust the padding between and around the subplots.Make a 2D data raster using an np.array.Display the data as an image, i.e., on a 2D regular raster.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 data = np.array( [[0.1, 0.7, 0.6, 0.3], [0.2, 0.6, 0.5, 0.2], [0.8, 0.3, 0.80, 0.01], [0.3, 0.4, 0.2, 0.1]] ) plt.imshow(data, interpolation="nearest", cmap="RdYlGn_r") plt.show()Output

447 Views
To plot a stacked event duration using Python Pandas, we can take the following stepsSet the figure size and adjust the padding between and around the subplots.Create a dataframe with lists of xmin and its corresponding xmax.Use hlines() method to plot a stacked event duration.To display the figure, use show() method.Exampleimport pandas as pd from datetime import datetime as dt from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True df = pd.DataFrame(dict(xmin=[dt.strptime('1994-07-19', '%Y-%m-%d'), dt.strptime('2006-03-16', '%Y-%m-%d'), dt.strptime('1980-10-31', '%Y-%m-%d'), dt.strptime('1981-06-11', '%Y-%m-%d'), dt.strptime('2006-06-28', '%Y-%m-%d')], ... Read More

107 Views
To make matplotlib in OSX work in a virtual environment, we can first create a virtual environment and then activate that created environment. Thereafter, install all the dependencies in that virtual environment.StepsOpen ubuntu terminal.apt-get install python-venvpython -m venv source /bin/activate

2K+ Views
To annotate subplots in a figure with A, B and C using matplotlib, we can take the following stepsSet the figure size and adjust the padding between and around the subplots.Create a figure and a set of subplots, with nrows=1 and ncols=3.Make a 1D iterator over an array.Iterate each axes and display data as an image.In the loop itself, place text A, B and C.To display the figure, use show() method.Exampleimport numpy as np from matplotlib import pyplot as plt import string plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig, axs = plt.subplots(1, 3) axs = axs.flat for index, ax ... Read More

7K+ Views
To connect two points on a 3D scatter plot, we can take the following stepsSet the figure size and adjust the padding between and around the subplots.Create a new figure or activate an existing figure using figure() method.Add an axes to the current figure as a subplot arrangement.Create lists for x, y and z.Plot x, y and z data points using scatter() methodTo connect the points, use plot() method with x, y and z data points with black color line.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 fig = ... Read More

705 Views
To control the alpha value on a 3D scatter plot using Python and Matplotlib, we can set the facecolor and edgecolors value.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.Add an '~.axes.Axes' to the figure as part of a subplot arrangement.Create x, y and z data points using numpy.Plot x, y and z points using scatter() method.Set the facecolors and edgecolors.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 = plt.figure() ax ... Read More