MATPLOTLIB CHARTS
QUESTION-1
Naman is doing some research. He has a stored line of Pascal’s triangle numbers as ar2 as
shown below: - ar2 = [1, 7, 21, 35, 35, 21, 7, 1].
He wants to plot the sine (use numpy.sin()), cosine (use numpy.cos()) and tangent values
(use numpy.tan()) for the same array ar2.
He wants cyan color for sine plot line, red color for cosine plot line, and the black color for
tangent plot line. Also, the tangent line should be dashed.
Also, the tangent line should be dashed.
Code:
OUTPUT:
QUESTION-2
Write a program to plot a scatter graph taking two random distributions in X1 and Y1 (both with
shape as (250), having randomly generated integers) and plotted against each other with varying
sizes and varying colors.
Code:
OUTPUT:
QUESTION-3
Write a program to plot a bar chart from the marks scored by you and your friends in different
subjects.
Code:
OUTPUT:
QUESTION-4
DPS School celebrated volunteering week where each section of class XI dedicated a day for
collecting amount for charity being supported by the school. Section A volunteered on Monday,
Bon Tuesday, C on Wednesday and so on. There are six sections in Class XI. Amounts collected
by sections A to F are 8000, 12000, 9800, 11200, 15500, 7300.
Code:
OUTPUT:
QUESTION-5
A survey gathers height and weight of 100 participants and recorded the participant’s ages:
-
Ages= [1,1,2,3,5,7,8,9,10,10,11,13,13,15,16,17,18,19,20,21,21,23,24,24,24,25,25,25,25,
26,26,26,27,27,27,27,27,29,30,30,30,30,31,33,34,34,34,35,36,36,37,37,37,38,38,39,40,40
,41,41,42,43,45,45,46,46,46,47,48,48,49,50,51,52,52,53,54,55,56,57,58,60,61,63,65,66,
68,70,72,74,75,77,81,83,84,87,89,90,91]
Write a program to plot a histogram from above data with 20 bins.
Code:
OUTPUT: