Page 262 - Robotics and AI class 10
P. 262

10.  Using different type of markers and line styles on the plot.

          Ans.  import numpy as np
              import matplotlib.pyplot as plt

              # Generate sample data for student marks
              num_students = 5

              subjects = ['Math', 'Science', 'SSt', 'English', '2nd Lang']

              student_names = ['Student ' + str(i) for i in range(1, num_students + 1)]
              marks = np.random.randint(40, 100, size=(num_students, len(subjects)))
              # Plotting student marks with different markers and line styles

              plt.figure(figsize=(10, 6))

              for i, subject in enumerate(subjects):
                  plt.plot(student_names, marks[:, i], marker='o', linestyle='-', label=subject)

              plt.xlabel('Students')
              plt.ylabel('Marks')

              plt.title('Student Marks with Different Markers and Line Styles')
              plt.legend()

              plt.xticks(rotation=45)
              plt.grid(True)

              plt.tight_layout()
              plt.show()
              Output:























          11.  Declaring labels for the axis. (Plot selling price and original price).

          Ans.  import pandas as pd
              import matplotlib.pyplot as plt

              # Create a small dataset with selling price and original price

              data = {

              260     Touchpad Robotics & Artificial Intelligence-X
   257   258   259   260   261   262   263   264   265   266   267