Matplotlib
import pandas as pd
import numpy as np
import matplotlib. pyplot as plt
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
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 )
plt. xlabel( 'month' )
plt. ylabel( 'value' )
plt. title( 'unrate' )
plt. show( )
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( )
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( )
ax. hist( norm_reviews[ 'Fandango_Ratingvalue' ] , range = ( 4 , 5 ) , bins= 20 )
plt. show( )
fig, ax = plt. subplots( )
ax. boxplot( norm_reviews[ 'RT_user_norm' ] )
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]))
sns. set ( )
sinplot( )
"""
五种风格
darkgrid
whitegrid
dark
white
ticks
"""
sns. set_style( 'whitegrid' )
sns. set_context( 'talk' )
sinplot( )
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. palplot( sns. hls_palette( 8 , l= 0.7 , s= 0.5 ) )