In [1]:
# importing matplotlib as usual
import numpy as np
%config InlineBackend.print_figure_kwargs = {'bbox_inches': None}
%matplotlib inline
import matplotlib.pyplot as plt
from IPython.display import set_matplotlib_formats
set_matplotlib_formats('pdf', 'png', 'svg')
sigma = 10
mu = 5
normal_random = np.random.randn(1000) * sigma + mu;
In [2]:
plt.bar([1, 2, 3, 4], [455, 404, 317, 730], tick_label=["XI", "IX", "VIII","V"], align='center');
plt.xlabel("Districts"); plt.ylabel("Avg price [10^3 HUF/ m^2]");
plt.title("Real estate prices in Budapest (2016)");
In [3]:
# provided matplotlib is imported and normal_random is a Gaussian distrib N(5, 10)
plt.hist(normal_random, color="g");
In [4]:
plt.boxplot(normal_random, labels=["Normal random"]);
In [5]:
plt.subplot(1,2,1) # create a 1-row 2-column figure, activate the 1st subplot
plt.boxplot(normal_random) # create a boxplot
plt.subplot(1,2,2) # activate the 2nd subplot
plt.hist(normal_random, orientation='horizontal', normed=True, color="g"); # create rotated histogram
plt.xticks(rotation=30);
In [21]:
xvars = np.arange(1,10,0.5);
plt.scatter(x=xvars, y=xvars**2, marker="x");
plt.scatter(x=xvars[1:6], y=xvars[1:6]**3, c="r", marker='o', s=xvars[1:6]**3*10); # using scatterplot as bubble-chart
In [7]:
from urllib.request import urlopen
import simplejson
from pandas.core.frame import DataFrame
commits = DataFrame(simplejson.loads(urlopen("https://api.github.com/repos/pydata/pandas/stats/punch_card").read()),
columns=["weekday","hour","commits"])
commits.head(3)
Out[7]:
In [8]:
import seaborn as sns
sns.heatmap(commits.pivot("weekday","hour","commits"));
numpy for data representationhelp())⬇︎