@codingboo
Elena Chen
3 years
#Day12 of #DataAnalytics #Matplotlib Creating figures through object-oriented method: create an empty canvas, then just call methods or attributes off of that object. - plt.figure() - plt.subplot(nrows=,ncols=)
1
0
0

Replies

@codingboo
Elena Chen
3 years
Many customizations: - figsize( , ) to adjust width and height of figure - colour of line (can be hex codes. alpha to indicate transparency of line) - linewidths (lw=) - linestyles (ls=) eg dashed/dotted eg 'b.-' blue line with dots - maker symbols 'o' '+' - marker size
1
0
0
@codingboo
Elena Chen
3 years
Adding a legend to the plot by specifying label=' ' in the method. (view pic) Can specify the position of legend by: axes.legend(loc=n) where the numeric signifies a specific position (view documentation). loc=0 to let matplotlib decide optimal location.
1
0
0
@codingboo
Elena Chen
3 years
Lastly, to specify specific x or y axes values, you can configure the ranges of axis using .set_xlim([lowerbound,upperbound]) (meaning to zoom into specific axes range)
0
0
0