Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7758555

Browse files
authored
Create Chapter 1
0 parents  commit 7758555

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

Chapter 1

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Ticks
2+
The customizations you've coded up to now are available in the script, in a more concise form.
3+
4+
In the video, Hugo has demonstrated how you could control the y-ticks by specifying two arguments:
5+
6+
plt.yticks([0,1,2], ["one","two","three"])
7+
In this example, the ticks corresponding to the numbers 0, 1 and 2 will be replaced by one, two and three, respectively.
8+
9+
Let's do a similar thing for the x-axis of your world development chart, with the xticks() function. The tick values 1000, 10000 and 100000 should be replaced by 1k, 10k and 100k. To this end, two lists have already been created for you: tick_val and tick_lab.
10+
11+
12+
# Scatter plot
13+
plt.scatter(gdp_cap, life_exp)
14+
15+
# Previous customizations
16+
plt.xscale('log')
17+
plt.xlabel('GDP per Capita [in USD]')
18+
plt.ylabel('Life Expectancy [in years]')
19+
plt.title('World Development in 2007')
20+
21+
# Definition of tick_val and tick_lab
22+
tick_val = [1000, 10000, 100000]
23+
tick_lab = ['1k', '10k', '100k']
24+
25+
# Adapt the ticks on the x-axis
26+
plt.xticks(tick_val,tick_lab)
27+
28+
# After customizing, display the plot
29+
plt.show()

0 commit comments

Comments
 (0)