Matplotlib

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# 常见的无衬线字体有 Trebuchet MS, Tahoma, Verdana, Arial, Helvetica,SimHei 中文的幼圆、隶书等等
plt.rcParams['font.sans-serif'] = ['FangSong']  # 指定默认字体
plt.rcParams['axes.unicode_minus'] = False  # 解决保存图像是负号'-'显示为方块的问题
data = pd.read_csv('data/unrate.csv')
data
DATE VALUE
0 1948-01-01 3.4
1 1948-02-01 3.8
2 1948-03-01 4.0
3 1948-04-01 3.9
4 1948-05-01 3.5
5 1948-06-01 3.6
6 1948-07-01 3.6
7 1948-08-01 3.9
8 1948-09-01 3.8
9 1948-10-01 3.7
10 1948-11-01 3.8
11 1948-12-01 4.0
12 1949-01-01 4.3
13 1949-02-01 4.7
14 1949-03-01 5.0
15 1949-04-01 5.3
16 1949-05-01 6.1
17 1949-06-01 6.2
18 1949-07-01 6.7
19 1949-08-01 6.8
20 1949-09-01 6.6
21 1949-10-01 7.9
22 1949-11-01 6.4
23 1949-12-01 6.6
24 1950-01-01 6.5
25 1950-02-01 6.4
26 1950-03-01 6.3
27 1950-04-01 5.8
28 1950-05-01 5.5
29 1950-06-01 5.4
... ... ...
794 2014-03-01 6.7
795 2014-04-01 6.2
796 2014-05-01 6.2
797 2014-06-01 6.1
798 2014-07-01 6.2
799 2014-08-01 6.2
800 2014-09-01 6.0
801 2014-10-01 5.7
802 2014-11-01 5.8
803 2014-12-01 5.6
804 2015-01-01 5.7
805 2015-02-01 5.5
806 2015-03-01 5.5
807 2015-04-01 5.4
808 2015-05-01 5.5
809 2015-06-01 5.3
810 2015-07-01 5.3
811 2015-08-01 5.1
812 2015-09-01 5.1
813 2015-10-01 5.0
814 2015-11-01 5.0
815 2015-12-01 5.0
816 2016-01-01 4.9
817 2016-02-01 4.9
818 2016-03-01 5.0
819 2016-04-01 5.0
820 2016-05-01 4.7
821 2016-06-01 4.9
822 2016-07-01 4.9
823 2016-08-01 4.9

824 rows × 2 columns

data.head()
DATE VALUE
0 1948-01-01 3.4
1 1948-02-01 3.8
2 1948-03-01 4.0
3 1948-04-01 3.9
4 1948-05-01 3.5
unrate = data.copy()
unrate['DATE'] = pd.to_datetime(unrate['DATE'])
unrate.head(12)
DATE VALUE
0 1948-01-01 3.4
1 1948-02-01 3.8
2 1948-03-01 4.0
3 1948-04-01 3.9
4 1948-05-01 3.5
5 1948-06-01 3.6
6 1948-07-01 3.6
7 1948-08-01 3.9
8 1948-09-01 3.8
9 1948-10-01 3.7
10 1948-11-01 3.8
11 1948-12-01 4.0
plt.plot()
plt.show()
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/matplotlib/font_manager.py:1331: UserWarning: findfont: Font family ['sans-serif'] not found. Falling back to DejaVu Sans(prop.get_family(), self.defaultFamily[fontext]))

first_twelve = unrate[0:12]
first_twelve
DATE VALUE
0 1948-01-01 3.4
1 1948-02-01 3.8
2 1948-03-01 4.0
3 1948-04-01 3.9
4 1948-05-01 3.5
5 1948-06-01 3.6
6 1948-07-01 3.6
7 1948-08-01 3.9
8 1948-09-01 3.8
9 1948-10-01 3.7
10 1948-11-01 3.8
11 1948-12-01 4.0
# x,y 默认是折线图
plt.plot(first_twelve['DATE'],first_twelve['VALUE'])
plt.show()

plt.plot(first_twelve['DATE'],first_twelve['VALUE'])
# 设置对应轴的角度
plt.xticks(rotation = 45)
plt.show()

plt.plot(first_twelve['DATE'],first_twelve['VALUE'])
# 设置对应轴的角度
plt.xticks(rotation = 45)
# 设置x轴的标签
plt.xlabel('month')
# 设置y轴的标签
plt.ylabel('value')
# 设置图的标题
plt.title('unrate')
plt.show()

# figsize=(10,10) 设置大小为10*10
fig = plt.figure(figsize=(10,10))
ax1 = fig.add_subplot(2,2,1)
ax2 = fig.add_subplot(2,2,2)
ax3 = fig.add_subplot(2,2,4)
ax1.plot(np.random.randint(1,5,5),np.arange(5))
ax2.plot(np.arange(10)*3,np.arange(10))
plt.show()

unrate['MONTH'] = unrate['DATE'].dt.month
print(unrate['MONTH'])
0       1
1       2
2       3
3       4
4       5
5       6
6       7
7       8
8       9
9      10
10     11
11     12
12      1
13      2
14      3
15      4
16      5
17      6
18      7
19      8
20      9
21     10
22     11
23     12
24      1
25      2
26      3
27      4
28      5
29      6..
794     3
795     4
796     5
797     6
798     7
799     8
800     9
801    10
802    11
803    12
804     1
805     2
806     3
807     4
808     5
809     6
810     7
811     8
812     9
813    10
814    11
815    12
816     1
817     2
818     3
819     4
820     5
821     6
822     7
823     8
Name: MONTH, Length: 824, dtype: int64
# 同一图表画多条线
fig = plt.figure(figsize=(5,5))
plt.plot(unrate[0:12]['MONTH'],unrate[0:12]['VALUE'],c='red',label='1948')
plt.plot(unrate[12:24]['MONTH'],unrate[12:24]['VALUE'],c='green',label='1949')
plt.legend(loc='best')
plt.show()

reviews = pd.read_csv('data/fandango_score_comparison.csv')
reviews
FILM RottenTomatoes RottenTomatoes_User Metacritic Metacritic_User IMDB Fandango_Stars Fandango_Ratingvalue RT_norm RT_user_norm ... IMDB_norm RT_norm_round RT_user_norm_round Metacritic_norm_round Metacritic_user_norm_round IMDB_norm_round Metacritic_user_vote_count IMDB_user_vote_count Fandango_votes Fandango_Difference
0 Avengers: Age of Ultron (2015) 74 86 66 7.1 7.8 5.0 4.5 3.70 4.30 ... 3.90 3.5 4.5 3.5 3.5 4.0 1330 271107 14846 0.5
1 Cinderella (2015) 85 80 67 7.5 7.1 5.0 4.5 4.25 4.00 ... 3.55 4.5 4.0 3.5 4.0 3.5 249 65709 12640 0.5
2 Ant-Man (2015) 80 90 64 8.1 7.8 5.0 4.5 4.00 4.50 ... 3.90 4.0 4.5 3.0 4.0 4.0 627 103660 12055 0.5
3 Do You Believe? (2015) 18 84 22 4.7 5.4 5.0 4.5 0.90 4.20 ... 2.70 1.0 4.0 1.0 2.5 2.5 31 3136 1793 0.5
4 Hot Tub Time Machine 2 (2015) 14 28 29 3.4 5.1 3.5 3.0 0.70 1.40 ... 2.55 0.5 1.5 1.5 1.5 2.5 88 19560 1021 0.5
5 The Water Diviner (2015) 63 62 50 6.8 7.2 4.5 4.0 3.15 3.10 ... 3.60 3.0 3.0 2.5 3.5 3.5 34 39373 397 0.5
6 Irrational Man (2015) 42 53 53 7.6 6.9 4.0 3.5 2.10 2.65 ... 3.45 2.0 2.5 2.5 4.0 3.5 17 2680 252 0.5
7 Top Five (2014) 86 64 81 6.8 6.5 4.0 3.5 4.30 3.20 ... 3.25 4.5 3.0 4.0 3.5 3.5 124 16876 3223 0.5
8 Shaun the Sheep Movie (2015) 99 82 81 8.8 7.4 4.5 4.0 4.95 4.10 ... 3.70 5.0 4.0 4.0 4.5 3.5 62 12227 896 0.5
9 Love & Mercy (2015) 89 87 80 8.5 7.8 4.5 4.0 4.45 4.35 ... 3.90 4.5 4.5 4.0 4.5 4.0 54 5367 864 0.5
10 Far From The Madding Crowd (2015) 84 77 71 7.5 7.2 4.5 4.0 4.20 3.85 ... 3.60 4.0 4.0 3.5 4.0 3.5 35 12129 804 0.5
11 Black Sea (2015) 82 60 62 6.6 6.4 4.0 3.5 4.10 3.00 ... 3.20 4.0 3.0 3.0 3.5 3.0 37 16547 218 0.5
12 Leviathan (2014) 99 79 92 7.2 7.7 4.0 3.5 4.95 3.95 ... 3.85 5.0 4.0 4.5 3.5 4.0 145 22521 64 0.5
13 Unbroken (2014) 51 70 59 6.5 7.2 4.5 4.1 2.55 3.50 ... 3.60 2.5 3.5 3.0 3.5 3.5 218 77518 9443 0.4
14 The Imitation Game (2014) 90 92 73 8.2 8.1 5.0 4.6 4.50 4.60 ... 4.05 4.5 4.5 3.5 4.0 4.0 566 334164 8055 0.4
15 Taken 3 (2015) 9 46 26 4.6 6.1 4.5 4.1 0.45 2.30 ... 3.05 0.5 2.5 1.5 2.5 3.0 240 104235 6757 0.4
16 Ted 2 (2015) 46 58 48 6.5 6.6 4.5 4.1 2.30 2.90 ... 3.30 2.5 3.0 2.5 3.5 3.5 197 49102 6437 0.4
17 Southpaw (2015) 59 80 57 8.2 7.8 5.0 4.6 2.95 4.00 ... 3.90 3.0 4.0 3.0 4.0 4.0 128 23561 5597 0.4
18 Night at the Museum: Secret of the Tomb (2014) 50 58 47 5.8 6.3 4.5 4.1 2.50 2.90 ... 3.15 2.5 3.0 2.5 3.0 3.0 103 50291 5445 0.4
19 Pixels (2015) 17 54 27 5.3 5.6 4.5 4.1 0.85 2.70 ... 2.80 1.0 2.5 1.5 2.5 3.0 246 19521 3886 0.4
20 McFarland, USA (2015) 79 89 60 7.2 7.5 5.0 4.6 3.95 4.45 ... 3.75 4.0 4.5 3.0 3.5 4.0 59 13769 3364 0.4
21 Insidious: Chapter 3 (2015) 59 56 52 6.9 6.3 4.5 4.1 2.95 2.80 ... 3.15 3.0 3.0 2.5 3.5 3.0 115 25134 3276 0.4
22 The Man From U.N.C.L.E. (2015) 68 80 55 7.9 7.6 4.5 4.1 3.40 4.00 ... 3.80 3.5 4.0 3.0 4.0 4.0 144 22104 2686 0.4
23 Run All Night (2015) 60 59 59 7.3 6.6 4.5 4.1 3.00 2.95 ... 3.30 3.0 3.0 3.0 3.5 3.5 141 50438 2066 0.4
24 Trainwreck (2015) 85 74 75 6.0 6.7 4.5 4.1 4.25 3.70 ... 3.35 4.5 3.5 4.0 3.0 3.5 169 27380 8381 0.4
25 Selma (2014) 99 86 89 7.1 7.5 5.0 4.6 4.95 4.30 ... 3.75 5.0 4.5 4.5 3.5 4.0 316 45344 7025 0.4
26 Ex Machina (2015) 92 86 78 7.9 7.7 4.5 4.1 4.60 4.30 ... 3.85 4.5 4.5 4.0 4.0 4.0 672 154499 3458 0.4
27 Still Alice (2015) 88 85 72 7.8 7.5 4.5 4.1 4.40 4.25 ... 3.75 4.5 4.5 3.5 4.0 4.0 153 57123 1258 0.4
28 Wild Tales (2014) 96 92 77 8.8 8.2 4.5 4.1 4.80 4.60 ... 4.10 5.0 4.5 4.0 4.5 4.0 107 50285 235 0.4
29 The End of the Tour (2015) 92 89 84 7.5 7.9 4.5 4.1 4.60 4.45 ... 3.95 4.5 4.5 4.0 4.0 4.0 19 1320 121 0.4
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
116 Clouds of Sils Maria (2015) 89 67 78 7.1 6.8 3.5 3.4 4.45 3.35 ... 3.40 4.5 3.5 4.0 3.5 3.5 36 11392 162 0.1
117 Testament of Youth (2015) 81 79 77 7.9 7.3 4.0 3.9 4.05 3.95 ... 3.65 4.0 4.0 4.0 4.0 3.5 15 5495 127 0.1
118 Infinitely Polar Bear (2015) 80 76 64 7.9 7.2 4.0 3.9 4.00 3.80 ... 3.60 4.0 4.0 3.0 4.0 3.5 8 1062 124 0.1
119 Phoenix (2015) 99 81 91 8.0 7.2 3.5 3.4 4.95 4.05 ... 3.60 5.0 4.0 4.5 4.0 3.5 21 3687 70 0.1
120 The Wolfpack (2015) 84 73 75 7.0 7.1 3.5 3.4 4.20 3.65 ... 3.55 4.0 3.5 4.0 3.5 3.5 8 1488 66 0.1
121 The Stanford Prison Experiment (2015) 84 87 68 8.5 7.1 4.0 3.9 4.20 4.35 ... 3.55 4.0 4.5 3.5 4.5 3.5 6 950 51 0.1
122 Tangerine (2015) 95 86 86 7.3 7.4 4.0 3.9 4.75 4.30 ... 3.70 5.0 4.5 4.5 3.5 3.5 14 696 36 0.1
123 Magic Mike XXL (2015) 62 64 60 5.4 6.3 4.5 4.4 3.10 3.20 ... 3.15 3.0 3.0 3.0 2.5 3.0 52 11937 9363 0.1
124 Home (2015) 45 65 55 7.3 6.7 4.5 4.4 2.25 3.25 ... 3.35 2.5 3.5 3.0 3.5 3.5 177 41158 7705 0.1
125 The Wedding Ringer (2015) 27 66 35 3.3 6.7 4.5 4.4 1.35 3.30 ... 3.35 1.5 3.5 2.0 1.5 3.5 126 37292 6506 0.1
126 Woman in Gold (2015) 52 81 51 7.2 7.4 4.5 4.4 2.60 4.05 ... 3.70 2.5 4.0 2.5 3.5 3.5 72 17957 2435 0.1
127 The Last Five Years (2015) 60 60 60 6.9 6.0 4.5 4.4 3.00 3.00 ... 3.00 3.0 3.0 3.0 3.5 3.0 20 4110 99 0.1
128 Mission: Impossible – Rogue Nation (2015) 92 90 75 8.0 7.8 4.5 4.4 4.60 4.50 ... 3.90 4.5 4.5 4.0 4.0 4.0 362 82579 8357 0.1
129 Amy (2015) 97 91 85 8.8 8.0 4.5 4.4 4.85 4.55 ... 4.00 5.0 4.5 4.5 4.5 4.0 60 5630 729 0.1
130 Jurassic World (2015) 71 81 59 7.0 7.3 4.5 4.5 3.55 4.05 ... 3.65 3.5 4.0 3.0 3.5 3.5 1281 241807 34390 0.0
131 Minions (2015) 54 52 56 5.7 6.7 4.0 4.0 2.70 2.60 ... 3.35 2.5 2.5 3.0 3.0 3.5 204 55895 14998 0.0
132 Max (2015) 35 73 47 5.9 7.0 4.5 4.5 1.75 3.65 ... 3.50 2.0 3.5 2.5 3.0 3.5 15 5444 3412 0.0
133 Paul Blart: Mall Cop 2 (2015) 5 36 13 2.4 4.3 3.5 3.5 0.25 1.80 ... 2.15 0.5 2.0 0.5 1.0 2.0 211 15004 3054 0.0
134 The Longest Ride (2015) 31 73 33 4.8 7.2 4.5 4.5 1.55 3.65 ... 3.60 1.5 3.5 1.5 2.5 3.5 49 25214 2603 0.0
135 The Lazarus Effect (2015) 14 23 31 4.9 5.2 3.0 3.0 0.70 1.15 ... 2.60 0.5 1.0 1.5 2.5 2.5 62 17691 1651 0.0
136 The Woman In Black 2 Angel of Death (2015) 22 25 42 4.4 4.9 3.0 3.0 1.10 1.25 ... 2.45 1.0 1.5 2.0 2.0 2.5 55 14873 1333 0.0
137 Danny Collins (2015) 77 75 58 7.1 7.1 4.0 4.0 3.85 3.75 ... 3.55 4.0 4.0 3.0 3.5 3.5 33 11206 531 0.0
138 Spare Parts (2015) 52 83 50 7.1 7.2 4.5 4.5 2.60 4.15 ... 3.60 2.5 4.0 2.5 3.5 3.5 7 47377 450 0.0
139 Serena (2015) 18 25 36 5.3 5.4 3.0 3.0 0.90 1.25 ... 2.70 1.0 1.5 2.0 2.5 2.5 19 12165 50 0.0
140 Inside Out (2015) 98 90 94 8.9 8.6 4.5 4.5 4.90 4.50 ... 4.30 5.0 4.5 4.5 4.5 4.5 807 96252 15749 0.0
141 Mr. Holmes (2015) 87 78 67 7.9 7.4 4.0 4.0 4.35 3.90 ... 3.70 4.5 4.0 3.5 4.0 3.5 33 7367 1348 0.0
142 '71 (2015) 97 82 83 7.5 7.2 3.5 3.5 4.85 4.10 ... 3.60 5.0 4.0 4.0 4.0 3.5 60 24116 192 0.0
143 Two Days, One Night (2014) 97 78 89 8.8 7.4 3.5 3.5 4.85 3.90 ... 3.70 5.0 4.0 4.5 4.5 3.5 123 24345 118 0.0
144 Gett: The Trial of Viviane Amsalem (2015) 100 81 90 7.3 7.8 3.5 3.5 5.00 4.05 ... 3.90 5.0 4.0 4.5 3.5 4.0 19 1955 59 0.0
145 Kumiko, The Treasure Hunter (2015) 87 63 68 6.4 6.7 3.5 3.5 4.35 3.15 ... 3.35 4.5 3.0 3.5 3.0 3.5 19 5289 41 0.0

146 rows × 22 columns

cols = ['FILM','RT_user_norm', 'Metacritic_user_nom', 'IMDB_norm', 'Fandango_Ratingvalue', 'Fandango_Stars']
norm_reviews = reviews[cols]
norm_reviews
FILM RT_user_norm Metacritic_user_nom IMDB_norm Fandango_Ratingvalue Fandango_Stars
0 Avengers: Age of Ultron (2015) 4.30 3.55 3.90 4.5 5.0
1 Cinderella (2015) 4.00 3.75 3.55 4.5 5.0
2 Ant-Man (2015) 4.50 4.05 3.90 4.5 5.0
3 Do You Believe? (2015) 4.20 2.35 2.70 4.5 5.0
4 Hot Tub Time Machine 2 (2015) 1.40 1.70 2.55 3.0 3.5
5 The Water Diviner (2015) 3.10 3.40 3.60 4.0 4.5
6 Irrational Man (2015) 2.65 3.80 3.45 3.5 4.0
7 Top Five (2014) 3.20 3.40 3.25 3.5 4.0
8 Shaun the Sheep Movie (2015) 4.10 4.40 3.70 4.0 4.5
9 Love & Mercy (2015) 4.35 4.25 3.90 4.0 4.5
10 Far From The Madding Crowd (2015) 3.85 3.75 3.60 4.0 4.5
11 Black Sea (2015) 3.00 3.30 3.20 3.5 4.0
12 Leviathan (2014) 3.95 3.60 3.85 3.5 4.0
13 Unbroken (2014) 3.50 3.25 3.60 4.1 4.5
14 The Imitation Game (2014) 4.60 4.10 4.05 4.6 5.0
15 Taken 3 (2015) 2.30 2.30 3.05 4.1 4.5
16 Ted 2 (2015) 2.90 3.25 3.30 4.1 4.5
17 Southpaw (2015) 4.00 4.10 3.90 4.6 5.0
18 Night at the Museum: Secret of the Tomb (2014) 2.90 2.90 3.15 4.1 4.5
19 Pixels (2015) 2.70 2.65 2.80 4.1 4.5
20 McFarland, USA (2015) 4.45 3.60 3.75 4.6 5.0
21 Insidious: Chapter 3 (2015) 2.80 3.45 3.15 4.1 4.5
22 The Man From U.N.C.L.E. (2015) 4.00 3.95 3.80 4.1 4.5
23 Run All Night (2015) 2.95 3.65 3.30 4.1 4.5
24 Trainwreck (2015) 3.70 3.00 3.35 4.1 4.5
25 Selma (2014) 4.30 3.55 3.75 4.6 5.0
26 Ex Machina (2015) 4.30 3.95 3.85 4.1 4.5
27 Still Alice (2015) 4.25 3.90 3.75 4.1 4.5
28 Wild Tales (2014) 4.60 4.40 4.10 4.1 4.5
29 The End of the Tour (2015) 4.45 3.75 3.95 4.1 4.5
... ... ... ... ... ... ...
116 Clouds of Sils Maria (2015) 3.35 3.55 3.40 3.4 3.5
117 Testament of Youth (2015) 3.95 3.95 3.65 3.9 4.0
118 Infinitely Polar Bear (2015) 3.80 3.95 3.60 3.9 4.0
119 Phoenix (2015) 4.05 4.00 3.60 3.4 3.5
120 The Wolfpack (2015) 3.65 3.50 3.55 3.4 3.5
121 The Stanford Prison Experiment (2015) 4.35 4.25 3.55 3.9 4.0
122 Tangerine (2015) 4.30 3.65 3.70 3.9 4.0
123 Magic Mike XXL (2015) 3.20 2.70 3.15 4.4 4.5
124 Home (2015) 3.25 3.65 3.35 4.4 4.5
125 The Wedding Ringer (2015) 3.30 1.65 3.35 4.4 4.5
126 Woman in Gold (2015) 4.05 3.60 3.70 4.4 4.5
127 The Last Five Years (2015) 3.00 3.45 3.00 4.4 4.5
128 Mission: Impossible – Rogue Nation (2015) 4.50 4.00 3.90 4.4 4.5
129 Amy (2015) 4.55 4.40 4.00 4.4 4.5
130 Jurassic World (2015) 4.05 3.50 3.65 4.5 4.5
131 Minions (2015) 2.60 2.85 3.35 4.0 4.0
132 Max (2015) 3.65 2.95 3.50 4.5 4.5
133 Paul Blart: Mall Cop 2 (2015) 1.80 1.20 2.15 3.5 3.5
134 The Longest Ride (2015) 3.65 2.40 3.60 4.5 4.5
135 The Lazarus Effect (2015) 1.15 2.45 2.60 3.0 3.0
136 The Woman In Black 2 Angel of Death (2015) 1.25 2.20 2.45 3.0 3.0
137 Danny Collins (2015) 3.75 3.55 3.55 4.0 4.0
138 Spare Parts (2015) 4.15 3.55 3.60 4.5 4.5
139 Serena (2015) 1.25 2.65 2.70 3.0 3.0
140 Inside Out (2015) 4.50 4.45 4.30 4.5 4.5
141 Mr. Holmes (2015) 3.90 3.95 3.70 4.0 4.0
142 '71 (2015) 4.10 3.75 3.60 3.5 3.5
143 Two Days, One Night (2014) 3.90 4.40 3.70 3.5 3.5
144 Gett: The Trial of Viviane Amsalem (2015) 4.05 3.65 3.90 3.5 3.5
145 Kumiko, The Treasure Hunter (2015) 3.15 3.20 3.35 3.5 3.5

146 rows × 6 columns

norm_reviews[:1]
FILM RT_user_norm Metacritic_user_nom IMDB_norm Fandango_Ratingvalue Fandango_Stars
0 Avengers: Age of Ultron (2015) 4.3 3.55 3.9 4.5 5.0
num_cols = ['RT_user_norm','Metacritic_user_nom','IMDB_norm','Fandango_Ratingvalue','Fandango_Stars']
bar_height = norm_reviews.loc[0,num_cols].values
bar_height
array([4.3, 3.55, 3.9, 4.5, 5.0], dtype=object)
bar_positions = np.arange(5) + 0.75
bar_positions
array([0.75, 1.75, 2.75, 3.75, 4.75])
fig,ax = plt.subplots()
# 0.3 为宽度占比
# bar 条形图
ax.bar(bar_positions,bar_height,0.3)
plt.show()

# 散点图
fig,ax = plt.subplots()
ax.scatter(norm_reviews['Fandango_Ratingvalue'],norm_reviews['RT_user_norm'])
ax.set_xlabel('Fandango_Ratingvalue')
ax.set_ylabel('RT_user_norm')
plt.show()

# 柱形图
#画图
fig,ax = plt.subplots()
#hist()表示带有bins结构,默认bins为10个。
#bins:某个变量过多,坐标轴就化不开,用bins化成范围,减少变量数量。
#ax.hist(norm_reviews['Fandango_Ratingvalue'])
#ax.hist(norm_reviews['Fandango_Ratingvalue'],bins=20) #指定bins为20个
#指定bins和指定横坐标区间
ax.hist(norm_reviews['Fandango_Ratingvalue'],range=(4,5),bins=20)
# set_ylim(x,y) 指定y轴的区间
plt.show()

# 箱型图 ----> 发布情况
fig,ax = plt.subplots()
ax.boxplot(norm_reviews['RT_user_norm'])
# 设置x轴的名称
ax.set_xticklabels(['Rotten'])
ax.set_ylim(0,5)
plt.show()

Seaborn

import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib as mlp
import numpy as np
%matplotlib inline
def sinplot(flip=1):x = np.linspace(0,14,1000)for i in range(1,7):plt.plot(x,np.sin(x+i*0.5)*(7-i)*flip)
sinplot()
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/matplotlib/font_manager.py:1331: UserWarning: findfont: Font family ['sans-serif'] not found. Falling back to DejaVu Sans(prop.get_family(), self.defaultFamily[fontext]))

# 使用seaborn模板
sns.set()
sinplot()

# 使用seaborn模板
"""五种风格darkgridwhitegriddarkwhiteticks
"""
sns.set_style('whitegrid')
# set_context('') 设置内容风格
sns.set_context('talk')
sinplot()

# 调色板
# set_palette() 设置所有图颜色
# color_palette() 设置图的颜色
# 默认颜色
current_palette = sns.color_palette()
print(current_palette)
sns.palplot(current_palette)
[(0.2980392156862745, 0.4470588235294118, 0.6901960784313725), (0.8666666666666667, 0.5176470588235295, 0.3215686274509804), (0.3333333333333333, 0.6588235294117647, 0.40784313725490196), (0.7686274509803922, 0.3058823529411765, 0.3215686274509804), (0.5058823529411764, 0.4470588235294118, 0.7019607843137254), (0.5764705882352941, 0.47058823529411764, 0.3764705882352941), (0.8549019607843137, 0.5450980392156862, 0.7647058823529411), (0.5490196078431373, 0.5490196078431373, 0.5490196078431373), (0.8, 0.7254901960784313, 0.4549019607843137), (0.39215686274509803, 0.7098039215686275, 0.803921568627451)]

# 第一个参数为颜色空间,第二个参数是返回的颜色个数
sns.palplot(sns.color_palette('hls',12))

# sns.hls_palette(8,l=0.7,s=0.5)
# l 表示亮度
# s 表示饱和度
sns.palplot(sns.hls_palette(8,l=0.7,s=0.5))



AI day04(2020 8/3)相关推荐

  1. 一站式了解多模态、金融、事理知识图谱构建指南 | AI ProCon 2020

    整理 | 许爱艳 出品 | AI科技大本营(ID:rgznai100) [导读]7 月 3-4 日,由 CSDN 主办的第三届 AI 开发者大会(AI ProCon 2020)在线上举行.本次大会有超 ...

  2. AI:2020 科大讯飞AI开发者大赛,总奖金池180+万元!拿下比赛,大厂offer到手,那么,你还在等什么?

    AI:2020 科大讯飞AI开发者大赛,iFLYTEK热浪来袭,总奖金池180+万元!拿下比赛,大厂offer到手,那么,你还在等什么? 导读:总奖金池180+万元,除此外,还有绿色就业通道& ...

  3. AI:2020年7月10日世界人工智能大会WAIC青少年人工智能创新发展论坛《人工智能从娃娃抓起》

    AI:2020年7月10日世界人工智能大会WAIC青少年人工智能创新发展论坛<人工智能从娃娃抓起> 导读:教育是生态系统,包括北大清华的本硕博正在逐设人工智能课程,五年以后,中国将会迈向人 ...

  4. AI:2020年WAIC世界人工智能大会2020年7月9日9:30-12:00开幕式《李彦宏、Elon Musk、马云等大佬演讲》

    AI:2020年WAIC世界人工智能大会2020年7月9日9:30-12:00开幕式<李彦宏.Elon Musk.马云等大佬演讲> 导读:大会开幕式由政府领导.顶尖科学家和知名企业家等演讲 ...

  5. AI:2020年6月北京智源大会演讲视频回放集合——分享博主体会与总结

    AI:2020年6月北京智源大会演讲视频回放集合--分享博主体会与总结 导读:首先感谢北京智源大会进行主题演讲的各领域顶级教授,博主受益匪浅,此文章为博主在聆听各领域教授或专家演讲时,一张一张截图进行 ...

  6. AI:2020年6月24日北京智源大会演讲分享之机器学习前沿青年科学家专题论坛——10:40-11:10金驰《Near-Optimal Reinforcement Learning with Sel》

    AI:2020年6月24日北京智源大会演讲分享之机器学习前沿青年科学家专题论坛--10:40-11:10金驰<Near-Optimal Reinforcement Learning with S ...

  7. AI:2020年6月23日北京智源大会顶级大佬邝子平、李开复 、陆奇、张亚勤、曹勖文进行云上圆桌论坛《探讨AI与创业》

    AI:2020年6月23日北京智源大会顶级大佬邝子平.李开复 .陆奇.张亚勤.曹勖文进行云上圆桌论坛<探讨AI与创业> 目录 2020年北京智源大会人顶级大佬邝子平.李开复 .陆奇.张亚勤 ...

  8. AI:2020年6月23日北京智源大会演讲分享之AI交通专题论坛——11:05-11:35杜博文教授《基于广义时空数据挖掘的交通复杂行为认知-从研究到工业》

    AI:2020年6月23日北京智源大会演讲分享之AI交通专题论坛--11:05-11:35杜博文教授<基于广义时空数据挖掘的交通复杂行为认知-从研究到工业> 目录 11:05-11:35  ...

  9. AI:2020年6月23日北京智源大会演讲分享之智能信息检索与挖掘专题论坛——09:55-10:40刘兵教授《Open-World AI and Continual Learning》

    AI:2020年6月23日北京智源大会演讲分享之智能信息检索与挖掘专题论坛--09:55-10:40刘兵教授<Open-World AI and Continual Learning> 导 ...

最新文章

  1. 银行卡睡眠多久才会被注销?
  2. 【c++算法刷题笔记】——洛谷1
  3. 20172327 2018-2019-1 《程序设计与数据结构》第八周学习总结
  4. 新闻列表页flex_C端列表页如何设计?
  5. 华为软件开发云发布管理测评报告
  6. oracle把所有表查询权限赋与另一用户
  7. mycat定时向mysql存储数据_【实战演练】Linux操作系统20-MyCat实现Mysql数据库读写分离与自动切换...
  8. 樊昌信通信原理第7版笔记和课后习题答案
  9. SQL注入基础语句大全
  10. java 多线程课件_Thread_java多线程参考源码_ppt_大学课件预览_高等教育资讯网
  11. after meet KeyNi liu
  12. 私募基金相关知识介绍(一)——TOT
  13. July 16th 模拟赛C T3 圆周舞蹈 Solution
  14. win10如何把txt更改为bat文件
  15. mac用什么写python程序_macos,python_大家在mac系统都用什么编辑器写python程序?,macos,python - phpStudy...
  16. PHP实验报告 点餐系统,点餐系统软件工程实验报告.doc
  17. elasticsearch启动报错:unable to install syscall filter: java.lang.UnsupportedOperationException: seccomp
  18. 清除win+r的记录
  19. Matlab 的判别分析 函数 : classify
  20. 多年前的《曹操传》存档修改器

热门文章

  1. 博文总集(三) 之网工进阶
  2. 牛客网小白月赛 10 A B C
  3. goland 未知文件打不开,删除“未知文件”默认关联类型:
  4. 量化金融分析AQF(12):配对交易 Pair trading - 考虑时间序列平稳性、协整关系
  5. ChatGPT 助力智能文案生成
  6. 单片机综合实验 - 06 | 数字温度计设计
  7. 2021-4-8应用
  8. 数据降维--------主成分分析(PCA)算法原理和实现学习笔记
  9. 通宵三天 我做了一个超级好玩的中秋节小游戏
  10. malformed packet mysql_MySQL Malformed Packet