- 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 1034 Articles for Matplotlib
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
514 Views
To plot multiple columns of a Pandas dataframe on the bar chart in matplotlib, we can take the following steps −Make a dictionary of different keys, between 1 to 10 range.Make a dataframe using Pandas dataframe.Create a bar plot, using the plot() method with kind=”bar”.To display the figure, use the show() method.Exampleimport pandas as pd from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True d = { 'y=1/x': [1 / i for i in range(1, 10)], 'y=x': [i for i in range(1, 10)], 'y=x^2': [i * i for i in range(1, 10)], 'y=x^3': [i ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
770 Views
To hide ticks label and keep the ticks in place, we can take the following steps −Initialize x1 and x10 variables to get the x and y points, using numpy.Plot points x and y using the plot() method.Using xticks method, get or set the current tick locations and labels of the X-axis. Pass no arguments to return the current values without modifying them. So, pass the range(x1, x10) to get ticks but pass an empty list to hide the labels.To display the figure, use the show() method.Exampleimport numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
982 Views
To get the list of figures in matplotlib, we can take the following steps −Using figure() method, create a new figure, or activate an existing figure. Creating x figures, i.e., x=3.To get the list of figures, use the plt.get_fignums() method.Examplefrom matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True plt.figure() plt.figure() plt.figure() print("Number of figures created: ", len(plt.get_fignums())) plt.show()OutputNumber of figures created: 3
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
3K+ Views
To get the color of the most recent plotted line, we can take the following steps −Create x and y points using numpy.Plot the line using x and y, with color red and linewidth 2.To get the color of the line, use the get_color() method, and print it.To display the figure, use the 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(1, 10, 1000) y = np.linspace(10, 20, 1000) line, = plt.plot(x, y, c="red", lw=2) print("Color of the most recent plot line: ", line.get_color()) plt.show()OutputColor of the most ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
456 Views
To set the log scale tick label number on the axes, we can take the following steps −Set x and y axis limits (1 to 100), using ylim and xlim, on both the axes.Using loglog() method, make a plot with log scaling on both the x and y axis.To display the figure, use the plot() method.Examplefrom matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True plt.ylim(1, 100) plt.xlim(1, 100) plt.loglog() plt.show()Output
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
6K+ Views
To plot a .wav file using matplotlib, we can take following the steps −To read a .wav file, we can use the read() method.After reading the .wav file, we will get a tuple. At the 0 th index, rate would be there and at the 1st index, array sample data.Use the plot() method to plot the .wav file.Set y and x labels using ylabel and xlabel with “Amplitude” and “Time” label, respectively.To display the figure, use the show() method.Examplefrom scipy.io.wavfile import read import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True input_data = read("my_audio.wav") audio = input_data[1] plt.plot(audio[0:1024]) plt.ylabel("Amplitude") plt.xlabel("Time") plt.show()OutputRead More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
4K+ Views
To increase the distance between the title and the plot in matplotlib, we can take the following steps −Create point x using numpy.Create point y using numpy sin.Set the title of the plot. After changing the value y (in argument), we can increase or decrease the distance between the title and the plot.Plot x and y points using the plot() method, where color is red and line width is 2.Ti display the figure, use the 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(1, 10, 1000) y = np.sin(x) ttl = ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
4K+ Views
LaTeX is a typesetting language for producing scientific documents. We use a very small part of the language for writing mathematical notation. Jupyter notebook recognizes LaTeX code written in markdown cells and renders the symbols in the browser using the MathJax JavaScript library.To write a LaTeX formula in the legend of a plot, we can take the following steps −Create data points for x.Create data point for y, i.e., y=sin(x).Plot the curve x and y with LaTex representation.To activate the label, use the legend() method.To display the figure, use the show() method.Exampleimport numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
2K+ Views
To draw grid lines behind matplotlib bar graph, we can take the following Steps −Make a list of numbers, i.e., data.Make a bar using the bar() method, by passing data, color='red' and alpha = 0.5. The alpha blending value should be between 0 (transparent) and 1 (opaque).To configure the grid lines, use the grid() method, with color='yellow', linewidth=1, axis='both' and alpha=0.5.To display the figure, show() method.Examplefrom matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True data = [3, 5, 9, 15, 12] plt.bar(range(len(data)), data, color='red', alpha=0.5) plt.grid(color='yellow', linewidth=1, axis='both', alpha=0.5) plt.show()OutputRead More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
370 Views
To plot parallel coordinates, we can take the following Steps −Load dataset iris using Seaborn (Need internet).Pass the loaded data into the parallel_coordinates() method, which will help in parallel plotting.To display the figure, use the show() method.Exampleimport matplotlib.pyplot as plt from pandas.plotting import parallel_coordinates import seaborn as sns plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True data = sns.load_dataset('iris') parallel_coordinates(data, 'species', colormap=plt.get_cmap("Set2")) plt.show()Output