Plot Flashcards
1
Q
Create a plot with logarithmic x and y scales
A
plt. scatter(gdp_cap, life_exp)
plt. xscale(‘log’)
plt. ysclate(‘log’)
plt.show()
2
Q
Create a scatter plot and change the axis to
1) x axis has values 1000, 10000, 100000
2) each x axis value is displayed as ‘1k’, ‘10k’, ‘100k’
3) name the axis
4) name the plot
5) change the dot size for each dot
6) change the color of each dot’
7) have gridlines
8) have text asside some dots
A
dot_sizes = [ int, Int , ... ] dot_colors = [ 'yellow', 'red', ... ] plt.plot(... s = dot_sizes, c = dot_colors) plt.ylabel('population') plt.xlabel('year') plt.xticks([ 1000, 10000, 100000 ], [ '1k', '10k', '100k' ] plt.title('population growth') plt.text(1550, 71, 'India') plt.text(5700, 80, 'China') plt.grid(True) plt.show()