In [1]:
import os
#os.chdir("/home/archimedeas/wrkspc/anaconda/the-visual-verdict/visualizations/1_the_senate/datasets")
os.getcwd()
Out[1]:
In [2]:
os.chdir('..')
os.getcwd()
os.chdir('datasets')
In [ ]:
import pandas as pd
df = pd.read_csv("1_age_group_5yr_span_trial.csv")
df
In [ ]:
labels = []
values = []
for i in range(13):
labels.append(str(df.iat[i,0]))
values.append(df.iat[i,1])
print(values, "\n\n", labels)
In [ ]:
%matplotlib inline
import matplotlib.pyplot as plt
plt.style.use('ggplot')
plt.rcParams["figure.figsize"] = (15,10)
In [ ]:
plt.plot(values)
In [3]:
plt.plot(values)
from bokeh import mpl
from bokeh.io import show, output_notebook
output_notebook()
show(mpl.to_bokeh())
In [4]:
import numpy as np
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ind = np.arange(13)
width = 0.35
p1 = plt.bar(ind, values, width)
ax.set_xticklabels(labels)
plt.show()
In [5]:
import numpy as np
import matplotlib.pyplot as plt
N = 50
x = np.random.rand(N)
y = np.random.rand(N)
colors = np.random.rand(N)
area = np.pi * (15 * np.random.rand(N))**2
plt.scatter(x, y, s=area, c=colors, alpha=0.5)
plt.show()
In [ ]:
plt.plot(range(12))
In [ ]:
plt.subplots(3)
In [6]:
from collections import OrderedDict
import pandas as pd
from bokeh._legacy_charts import Donut, show, output_file
from bokeh.sampledata.olympics2014 import data
# throw the data into a pandas data frame
df = pd.io.json.json_normalize(data['data'])
# filter by countries with at least one medal and sort
df = df[df['medals.total'] > 8]
df = df.sort("medals.total", ascending=False)
# get the countries and we group the data by medal type
countries = df.abbr.values.tolist()
gold = df['medals.gold'].astype(float).values
silver = df['medals.silver'].astype(float).values
bronze = df['medals.bronze'].astype(float).values
# build a dict containing the grouped data
medals = OrderedDict()
medals['bronze'] = bronze
medals['silver'] = silver
medals['gold'] = gold
# any of the following commented are also valid Donut inputs
#medals = list(medals.values())
#medals = np.array(list(medals.values()))
#medals = pd.DataFrame(medals)
output_file("donut.html")
donut = Donut(medals, countries)
show(donut)
In [7]:
from bokeh._legacy_charts import Bar
from bokeh.io import output_notebook, show
# get the countries and we group the data by medal type
states = ['delhi', 'assam']
delhi = [ [56,46],
[23,77],
[45,55],
[60,40],
[35,15,25,25]
]
assam = [ [46,56],
[33,67],
[75,25],
[50,50],
[75,5,10,10]
]
output_notebook()
bar = Bar([delhi[0],assam[0]], states, title="Stacked bars", stacked=True)
bar2 = Bar([delhi[0],assam[0]], states, title="Stacked bars")
show(bar)
In [66]:
from bokeh.plotting import figure, vplot, hplot, output_notebook, output_file
from bokeh.models import *
In [80]:
fig = figure(width=400, height=400)
fig.line([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], line_width = 50, line_color= "red")
fig1 = figure(width=400, height=400)
fig1.circle(1,3,size = 10)
#output_file("test-plot")
BoxAnnotation()
output_notebook()
show(hplot(fig,fig1))
In [89]:
from bokeh.plotting import figure, output_file, show
plot = figure()
plot.annulus(x=[1, 2, 3], y=[1, 2, 3], color="#7FC97F",
inner_radius=0.2, outer_radius=0.5, fill_alpha = 0.5)
plot.grid.grid_line_color = "red"
#plot.axis.axis_line_color = "purple"
plot.axis.major_tick_line_color = "green"
show(plot)
In [ ]: