-
Notifications
You must be signed in to change notification settings - Fork 0
/
genrecountries.py
107 lines (85 loc) · 2.37 KB
/
genrecountries.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
from datetime import datetime
from bokeh.plotting import figure, show, output_file
from bokeh.models import ColumnDataSource, NumeralTickFormatter
from bokeh.transform import dodge
from bokeh.core.properties import value
from bokeh.io import output_notebook
output_notebook()
# create output filea
output_file("genrecountries.html")
# countries for foreign market
countries=["Argentina",
"Australia",
"Belgium",
"Brazil",
"China",
"Colombia"
]
# top 5 movies for the genre
top_movies=[
"Forrest Gump",
"Saving Private Ryan",
"Pearl Harbor",
"Dunkirk",
"Gladiator"
]
# gross earnings of the top 5 movies in the foreign market
fGump=[4999308,
22839211,
5562917,
5381320,
5062459,
6865078]
pvtRyan=[4376869,
46822002,
5654123,
6681146,
9543153,
3268925]
pHrbr=[3331732,
54385465,
4061231,
6904807,
6300000,
7140604]
Dnkrk=[2310437,
33829034,
5003952,
7569037,
1473064,
1507057]
Gldtr=[1480477,
39880001,
4435611,
20156555,
0,
3651300]
data = {"countries" : countries,
top_movies[0] : fGump,
top_movies[1] : pvtRyan,
top_movies[2] : pHrbr,
top_movies[3] : Dnkrk,
top_movies[4] : Gldtr}
source = ColumnDataSource(data=data)
# create a new plot with a title y_axis range and plot height
p = figure(x_range=countries, y_range=(0,400000000),plot_height=450,title="")
# creating bar charts for the top 5 movies with color codes
p.vbar(x=dodge('countries', -0.34, range=p.x_range), top=top_movies[0], width=0.15,
source=source,color="#c9d9d3", legend=value(top_movies[0]))
p.vbar(x=dodge('countries', -0.17, range=p.x_range), top=top_movies[1], width=0.15,
source=source,color="#718dbf", legend=value(top_movies[1]))
p.vbar(x=dodge('countries', 0.0, range=p.x_range), top=top_movies[2], width=0.15,
source=source,color="#e84d60", legend=value(top_movies[2]))
p.vbar(x=dodge('countries', 0.17, range=p.x_range), top=top_movies[3], width=0.15,
source=source,color="#008000", legend=value(top_movies[3]))
p.vbar(x=dodge('countries', 0.34, range=p.x_range), top=top_movies[4], width=0.15,
source=source,color="#cd853f", legend=value(top_movies[4]))
# creating format for the y axis lables
p.yaxis[0].formatter = NumeralTickFormatter(format="($ 0.00 a)")
# removing the x axis grid
p.xgrid.grid_line_color = None
# positioning the legend
p.legend.location = "top_left"
p.legend.orientation = "vertical"
# to show the result
show(p)