Matplotlib Cheat Sheet (Class 12 IP)
Code Meaning
[Link](x,y) Draws a line graph between x and y
[Link]('Name') Adds a title to the graph
[Link]('X-axis') Labels the X-axis
[Link]('Y-axis') Labels the Y-axis
[Link]([1,2,3],['A','B','C']) Custom ticks/labels on X-axis
[Link]([10,20,30]) Sets Y-axis ticks (scale values)
[Link](x,y) Vertical bar chart
[Link](x,y) Horizontal bar chart
[Link](data,bins=5) Histogram with 5 intervals
[Link](sizes,labels=names) Pie chart with labels
[Link](True) Shows grid lines
[Link]() Displays legend (labels of plots)
[Link](r,c,n) Multiple plots (row, col, number)
[Link]() Displays the final graph
Line Styles Meaning
linestyle='-' Solid line (default)
linestyle='--' Dashed line
linestyle=':' Dotted line
linestyle='-.' Dash-dot line
Marker Styles Meaning
marker='o' Circle marker
marker='s' Square marker
marker='^' Triangle marker
marker='*' Star marker
marker='d' Diamond marker
Color Codes Meaning
color='r' Red
color='g' Green
color='b' Blue
color='k' Black
color='y' Yellow