- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to make several plots on a single page using matplotlib in Python?
Using Pandas, we can create a data frame and create a figure and axis. After that, we can use the scatter method to draw points.
Create lists of students, marks obtained by them, and color codings for each score.
Make a data frame using Panda’s DataFrame, with step 1 data.
Create fig and ax variables using subplots method, where default nrows and ncols are 1.
Set the X-axis label using plt.xlabel() method.
Set the Y-axis label using plt.ylabel() method.
A scatter plot of *y* vs. *x* with varying marker size and/or color.
To show the figure, use plt.show() method.
from matplotlib import pyplot as plt import pandas as pd no_of_students = [1, 2, 3, 5, 7, 8, 9, 10, 30, 50] marks_obtained_by_student = [100, 95, 91, 90, 89, 76, 55, 10, 3, 19] color_coding = ['red', 'blue', 'yellow', 'green', 'red', 'blue', 'yellow', 'green', 'yellow', 'green'] df = pd.DataFrame(dict(students_count=no_of_students, marks=marks_obtained_by_student, color=color_coding)) fig, ax = plt.subplots() plt.xlabel('Students count') plt.ylabel('Obtained marks') ax.scatter(df['students_count'], df['marks'], c=df['color']) plt.show()
- How to make several plots on a single page using Matplotlib(Python)?
- How to make several plots on a single page using Matplotlib?
- How to make semilogx and semilogy plots in Matplotlib?
- How to make several legend keys to the same entry in Matplotlib?
- How to make two plots side-by-side using Python?
- How to make a page redirect using jQuery?
- How to reuse plots in Matplotlib?
- How do I show the same Matplotlib figure several times in a single IPython notebook?
- How to make page links in HTML Page?
- How can Matplotlib be used to three-dimensional line plots using Python?
- How to make colorbar orientation horizontal in Python using Matplotlib?
- How to make markers on lines smaller in Matplotlib?
- How to add annotations in Matplotlib Plots?
- How to align multiple plots in a grid using GridSpec Class in Matplotlib
- How to Join Several Partitions on Linux